是什么样的格式 2012-05-02T15:44:20.000Z
我一直试图解析它,但是在本节中遇到了一些问题。
NSString *articleDateString = [item valueForChild:@"published"];
NSDate *articleDate = [NSDate dateFromInternetDateTimeString:articleDateString formatHint:DateFormatHintRFC822];
NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
NSString *dateofarticle = [dateFormatter stringFromDate:articleDate];
它不是RFC822。这就是我所知道的全部。
答案 0 :(得分:0)
NSString *articleDateString = [item valueForChild:@"published"];
NSDate *articleDate = [NSDate dateFromInternetDateTimeString:articleDateString formatHint:DateFormatHintRFC822];
NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateStyle:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'"];
NSString *dateofarticle = [dateFormatter stringFromDate:articleDate];