낯선 질문이 발생했습니다. NSDateFormatter는 iOS 6에서 NSDate 인스턴스에 1988-04-10
을 구문 분석 할 수 없습니다. 그러나 iOS 4 및 iOS 5에서 작동합니다. 버그입니까?NSDateFormatter는 '1988-04-10'을 iOS 6의 NSDate 인스턴스로 구문 분석 할 수 없습니다. 그게 버그 야?
다음은 코드입니다. 그것은 매우 간단합니다. 다음은
NSArray *values = @[@"1988-04-09", @"1988-04-10", @"1988-04-11"];
NSDateFormatter* df = [[NSDateFormatter alloc] init];
NSLocale *posixLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[df setLocale:posixLocale];
[df setDateFormat:@"yyyy'-'MM'-'dd"];
NSLog(@"timeZone:%@, locale:%@", df.timeZone, df.locale.localeIdentifier);
NSDate* date = nil;
for (NSString *value in values) {
date = [df dateFromString:value];
NSLog(@"The date is %@", date);
}
[posixLocale release];
[df release];
그것은 1988-04-10
위한 널 iOS의 제
2013-03-19 09:42:40.824 SampleProject[1455:11303] timeZone:Asia/Shanghai (GMT+08:00) offset 28800, locale:en_US_POSIX
2013-03-19 09:42:40.827 SampleProject[1455:11303] The date is 1988-04-08 16:00:00 +0000
2013-03-19 09:42:40.827 SampleProject[1455:11303] The date is (null)
2013-03-19 09:42:40.828 SampleProject[1455:11303] The date is 1988-04-10 15:00:00 +0000
의 결과 아이폰 OS 4 및 iOS 5. 다음
2013-03-19 09:55:32.249 SampleProject[1844:f803] timeZone:Asia/Shanghai (CST (China)) offset 28800, locale:en_US_POSIX
2013-03-19 09:55:32.250 SampleProject[1844:f803] The date is 1988-04-08 16:00:00 +0000
2013-03-19 09:55:32.250 SampleProject[1844:f803] The date is 1988-04-09 16:00:00 +0000
2013-03-19 09:55:32.251 SampleProject[1844:f803] The date is 1988-04-10 15:00:00 +0000
의 결과이다. Is is a bug. 아무도 그것을 설명 할 수 있습니까?
실제로, http://www.timeanddate.com/worldclock/timezone.html?n=237&syear=1980 – Joni
그건 당신이 알고있는 미친 짓이야 !! +1 – borrrden
쿨, 그 이유입니다. 고맙습니다. –