NSDateFormatter getting Null

邮差的信 提交于 2019-12-20 05:39:07

问题


I in my project I am getting a string I am passing the string to the dateFormatter but I am getting nil, in the string instead of IST I may get PDT I may get any other formats,

NSString* currentDateString = @"2012-11-09 12:31:53.0 **IST**";

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.S z"];

NSDate *dateFromString = [dateFormatter dateFromString:currentDateString];

回答1:


If you are testing on iOS 6.0+ device/simulator only, test it on below iOS 6.0 device. I think in Ios 6.0+ something is changed related to abbreviations. Abbreviations dictionary in iOS 6.0+ contains different values than in iOS below 6.0.



来源:https://stackoverflow.com/questions/13449004/nsdateformatter-getting-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!