如何将格式 (2013-07-25T06:15:33.180-04:00) 的 NSString 转换为 NSDate?
我正在尝试使用以下代码进行转换
NSDateFormatter *rfc3339TimestampFormatterWithTimeZone = [[NSDateFormatter alloc] init];
[rfc3339TimestampFormatterWithTimeZone setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
[rfc3339TimestampFormatterWithTimeZone setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss ZZZ"];
NSDate *theDate = nil;
NSError *error = nil;
if (![rfc3339TimestampFormatterWithTimeZone getObjectValue:&theDate forString:dateString range:nil error:&error]) {
NSLog(@"Date '%@' could not be parsed: %@", dateString, error);
}
NSString *strDate = [rfc3339TimestampFormatterWithTimeZone stringFromDate:theDate];
return strDate;
请帮我