我试图在日历设置为日语时显示 NSDate 的 4 位公历年。
NSLog(@"Date joined: %@", self.dateJoined);
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.calendar = calendar;
formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"EST"];
formatter.dateFormat = @"yyyy";
NSLog(@"Year joined: %@", [formatter stringFromDate:self.dateJoined]);
日志:
Date joined: 2012-05-29 22:13:54 +0000
Year joined: 4000
我究竟做错了什么?