0
我試圖在日曆設置爲日語時顯示NSDate的4位數公曆年。當iOS設置中的日曆是日語或佛教徒時,如何顯示公曆日曆年的NSDate
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
我在做什麼錯?
您是否試過「en_US_POSIX」而不是「en_US」? –
@MartinR我只是試了一下,並得出相同的結果。 –