我尝试将我NSDateFormatter
的设置设置为德语,但它失败了。在下面的代码中,虽然dateFrom
成功解析,dateTo
但不是。
注意:在德语中是二月,而不是二月。
NSLocale *germanLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"de_DE"];
NSString *formatString = [NSDateFormatter dateFormatFromTemplate:@"dd. MMMM" options:0
locale:germanLocale];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:formatString];
NSDate *dateFrom = [dateFormat dateFromString:@"20. September"];
NSDate *dateTo = [dateFormat dateFromString:@"20. Februar"];