Potential bug with NSDateFormatter in iOS6

Originator:thelbane
Number:rdar://12385667 Date Originated:9/27/2012
Status:Open Resolved:
Product:iOS Product Version:6.0
Classification:Bug Reproducible:Yes
 
Summary:
NSDateFormatter returns incorrect year for years >= 3512

Steps to Reproduce:
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);

Expected Results:
4001-01-01T00:00:00.000Z -- 4001-01-01 00:00:00 +0000

Actual Results:
4001-01-01T00:00:00.000Z -- 2001-01-01 00:00:00 +0000

Regression:
Same code snippet returns correct results in iOS 5.1.

Notes:
Independently verified on StackOverflow:
http://stackoverflow.com/questions/12610157/potential-bug-with-nsdateformatter-in-ios6-has-anyone-else-encountered-this

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!