繁体   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