我真的对 NSDate 和 NSDateFormatter 感到困惑。我正在尝试从 twitter REST api 1.1 解析日期。我的 DateFormat 似乎是错误的,但我几乎 100% 确定它是正确的。执行 dateFromString 后我得到一个空值
这是我的代码
- (void)InitTwitterToMatchingArray
{
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setDateFormat:@"EEE MMM dd HH:mm:ss '+0000' yyyy"];
for (int i = 0; i < [twitterParser1 getAmountOfTweets]; i++) {
AktuelltMatching *amObject = [AktuelltMatching alloc];
amObject.ID = i;
amObject.type = @"twitter";
NSString *dateString1 = [twitterParser1 getDateForIndex:i];
NSLog(@"date BEFORE parse : %@", dateString1);
amObject.date = [dateFormatter1 dateFromString:dateString1];
[AktuelltMatchingArray addObject:amObject];
NSLog(@"date AFTER parse %@", amObject.date);
}
}
这是我的日志
VasaSvahnFirstPrototype[481:907] date BEFORE parse : Fri Apr 26 22:44:06 +0000 2013
2013-06-25 20:03:56.505 VasaSvahnFirstPrototype[481:907] date AFTER parse (null)
2013-06-25 20:03:56.506 VasaSvahnFirstPrototype[481:907] date BEFORE parse : Fri Apr 26 22:43:48 +0000 2013
2013-06-25 20:03:56.507 VasaSvahnFirstPrototype[481:907] date AFTER parse (null)
2013-06-25 20:03:56.508 VasaSvahnFirstPrototype[481:907] date BEFORE parse : Wed Apr 10 13:51:06 +0000 2013
2013-06-25 20:03:56.509 VasaSvahnFirstPrototype[481:907] date AFTER parse (null)
2013-06-25 20:03:56.509 VasaSvahnFirstPrototype[481:907] date BEFORE parse : Fri Mar 22 14:51:45 +0000 2013
2013-06-25 20:03:56.510 VasaSvahnFirstPrototype[481:907] date AFTER parse (null)
2013-06-25 20:03:56.513
我在这里做错了什么?