當runDate的值是@「Fri,2013年11月1日08:47:33 GMT-0500」時,我在iOS 7 iPhone模擬器上得到零,但在iOS 6 iPhone模擬器上沒問題爲什麼NSDateFormatter在iOS 7上返回零號
NSString *runDate = [reportDictionary objectForKey:@"runDate"];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
formatter.dateFormat = @"EEE, dd MMM yyyy HH:mm:ss ZZZ";
NSDate *actualRunDate = [formatter dateFromString:runDate];
我結束了零的在iOS模擬器7的actualRunDate但不能在iOS 6.1
我怎樣才能得到它在iOS 7的工作?
時區格式應該是'ZZZZ'(4個Zs,而不是3個)。 – rmaddy
@rmaddy可能是解決方案。但請注意,時區可以是3個或4個字母,具體取決於它提供的方式:「時區 - 具有特定的非位置格式。如果不可用,則返回到本地化的GMT格式。短格式或全格式的四格。在短格式中,除非常用的標誌在區域設置中打開,否則不會使用元區名稱。「 –
使用這種格式,我仍然沒有。 @「EEE,dd MMM yyyy HH:mm:ss ZZZZ」 – finneycanhelp