Objective c iOS6中NSDateFormatter的潜在错误。还有其他人遇到过这种情况吗?
我们马上就去。下面是代码片段:Objective c iOS6中NSDateFormatter的潜在错误。还有其他人遇到过这种情况吗?,objective-c,date,ios6,nsdateformatter,Objective C,Date,Ios6,Nsdateformatter,我们马上就去。下面是代码片段: NSString *dateString = @"4001-01-01T00:00:00.000Z"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; [dateFormatter setTimeZone:timeZone]; [dateFormatter set
NSString *dateString = @"4001-01-01T00:00:00.000Z";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
[dateFormatter setTimeZone:timeZone];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"];
NSDate *date = [dateFormatter dateFromString:dateString];
NSLog(@"%@ -- %@", dateString, date);
为iPhone 5.1模拟器或iOS 5.1设备构建时的结果:
4001-01-01T00:00:00.000Z -- 4001-01-01 00:00:00 +0000
为iPhone 6.0模拟器或iOS 6设备构建时的结果:
4001-01-01T00:00:00.000Z -- 2001-01-01 00:00:00 +0000
请注意-,之后输出年份中的差异
我们已经确定,在iOS 6中,日期格式化程序从3512 1500年后的任何日期中减去2000年
有没有其他人经历过这种情况和/或有过优雅的解决方法
谢谢。我很好奇,想试试这个。。。是的,我可以验证5.1和6.0模拟器之间的差异。我不知道为什么。。。至少还没有。我想这已经被其他人注意到了。也许你应该创建一个ios6 bug标签或类似的东西。@stackmonster看看第一个代码块下面:为iPhone 5.1模拟器或iOS 5.1设备构建时的结果:我在Apple打开了一个bug:你并不孤单,似乎: