簡體   English   中英

NSDateFormatter在iOS5.0,iOS6.0中返回null

[英]NSDateFormatter returning null in iOS5.0, iOS6.0

我從服務器轉換為日期字符串。 下面是我正在使用的代碼。

NSString *endDateString = @"2014-03-01T00:00:00-08:00";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
NSDate *eventEndDate = [dateFormatter dateFromString:endDateString];
NSLog(@"%@", eventEndDate);

它在iOS7.0中運行良好,但在iOS 5.0和6.0中為我提供了NULL。

對於帶有嵌入式“:”的時間軸偏移,日期格式不正確。

采用:

[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZZ"];

發件人:ICU 格式化日期和時間

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM