NSDateFormatter problem with weekday EEE

瘦欲@ 提交于 2019-12-12 16:36:36

问题


Why does the following code output: Dday: (null)

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"EEE HH:mm:ss"];
NSDate *date = [dateFormatter dateFromString:@"Sun 15:00:00"];
DLog(@"Ddate: %@", date);

If I use the format HH:mm:ss and string 15:00:00 i get a valid date...

Cheers mate


回答1:


It may be related to the locale of your system/device, have a look at the following from apple

http://developer.apple.com/mac/library/qa/qa2010/qa1480.html




回答2:


Are you sure it should be EEE not eee? I was using eee and it works fine.



来源:https://stackoverflow.com/questions/3600748/nsdateformatter-problem-with-weekday-eee

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