NSDateFormatter::initWithDateFormat = fails but setDateFormat = works
Originator: | Pich.Dominik | ||
Number: | rdar://10182802 | Date Originated: | 09-25-2011 |
Status: | Closed | Resolved: | NO |
Product: | MacOSX SDK | Product Version: | 10.8 |
Classification: | Other Bug | Reproducible: | Always |
Summary: when I use initWithDateFormat the formatter fails for some formats, when I call setDateFormat it works just fine Steps to Reproduce: Execute attached test case which shows the problem again ==> //show whats wrong for bug - (void)testParsingSimpleDateString { NSString *string = @"Juli 13, 2010"; NSString *dateString = @"MMMM dd, yyyy"; NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"de_DE"]; NSDate *date = nil; //method a NSString *errorString = nil; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:dateString]; [formatter setLocale:locale]; BOOL br = [formatter getObjectValue:&date forString:string errorDescription:&errorString]; if(!br) { NSLog(@"%@, %@", errorString, [locale displayNameForKey:NSLocaleIdentifier value:@"de_DE"]); date = nil; } else { NSLog(@"%@", date); } GHAssert #if TARGET_OS_IPHONE #else //method b errorString = nil; date = nil; formatter = [[NSDateFormatter alloc] initWithDateFormat:dateString allowNaturalLanguage:NO]; [formatter setDateFormat:dateString]; [formatter setLocale:locale]; br = [formatter getObjectValue:&date forString:string errorDescription:&errorString]; if(!br) { NSLog(@"%@, %@", errorString, [locale displayNameForKey:NSLocaleIdentifier value:@"de_DE"]); date = nil; } else { NSLog(@"%@", date); } #endif }
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!
ADR: We are closing this bug since our engineers are aware of the issue, and they have determined that the issue behaves as intended. If you have questions regarding the resolution of this issue, please update your bug report with them.
me: I dont see how you could close this. the issue STILL remains and can be seen easily :)
and
behave differently for some date string