3
我在做什麼錯了?NSDateFormatter stringFromDate不尊重自定義模式的區域設置
我想讓NSDateFormatter爲使用當前語言環境的日期翻譯自定義模式。
例子:
dateFormat = [[NSDateFormatter alloc] init];
dateFormat.locale = [NSLocale currentLocale];
[dateFormat setDateFormat:@"MMM"];
output = [self.dateFormat stringFromDate:dateObject];
不管我怎麼改變我的當前區域設置,我總是看英文縮寫一個月。
感謝您提供的任何幫助。
請'NSLog(@「%@」,[[NSLocale currentLocale] identifier])'確認您沒有使用英文區域設置。 – kennytm 2010-11-10 17:41:55
所以現在我很困惑。我正在模擬器中工作,該模擬器目前設置爲意大利語。系統'完成'按鈕似乎被翻譯......它說'很好',但是當我記錄currentLocale標識符時,正如你所建議的那樣,它說en_US。有些事情是不對的。 – toofah 2010-11-11 04:34:36