如何为NSDateFormatter设置语言环境?我试过下面的代码,它不工作。NSDateFormatter语言环境
- (NSString *)localizedStringWithFormat:(NSString *)format {
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:format];
NSCalendar *cal = [NSCalendar currentCalendar];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier: @"fr_FR"];
cal.locale = locale;
df.calendar = cal;
return [df stringFromDate:self];
}
请让我知道如何使这项工作。
谢谢。
我只是直接设置日期格式的语言环境。我必须检查确定,但是您的方案可能会为currentCalendar的* every *用户设置语言环境。 (不明显,为什么它不会工作,否则。) –
顺便说一下,是什么让你说它不工作? –
将您的期望结果添加到您的问题将是很好的。或者你收到什么结果会让你觉得它不起作用。记住Xcode NSLog中显示的日期/时间是GMT。 –