RSS フィードを解析しようとしていますが、日付の解析が困難です。日付文字列は次のとおりです。publishedDate = "2013-01-08T20:09:02.000Z"
これが私のコードです:
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 時間に変換しようとしています。