我想解析一个RSS源,但日期很难解析。日期字符串是:publishedDate = "2013-01-08T20:09:02.000Z"
NSDateFormatter麻烦?
这里是我的代码:
NSDateFormatter *utc = [[NSDateFormatter alloc] init];
[utc setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
[utc setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
NSDate *dtUTC = [utc dateFromString: publishedDate];
NSDateFormatter *dfLocal = [[NSDateFormatter alloc] init];
[dfLocal setDateFormat:@"yyyy-MM-dd"];
[dfLocal setTimeZone:[NSTimeZone localTimeZone]];
NSString *time =[dfLocal stringFromDate:dtUTC];
NSLog(@"original UTC %@ now local: %@", dtUTC, time);
为什么date
返回nil?此外,我试图将UTC时间转换为CST时间。
什么是'publishedDate'? – wigging
串... 2013-01-08T20:09:02.000Z –