小编aru*_*t21的帖子

NSDateFormatter区域设置

如何为NSDateFormatter设置Locale?我已经尝试了以下代码,但它不起作用.

- (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];
}
Run Code Online (Sandbox Code Playgroud)

请让我知道如何使这项工作.

谢谢.

iphone objective-c nsdateformatter ios

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

ios ×1

iphone ×1

nsdateformatter ×1

objective-c ×1