我試圖本地化我的日期,但由於某些原因,它不會從區域輸出正確的格式。NSDateFormatter不根據地區給出consitent日期
這是怎麼測試我的代碼:
if(dateformater==nil)
dateformater =[[NSDateFormatter alloc] init];
[dateformater setLocale:[NSLocale currentLocale]];
[dateformater setDateStyle:NSDateFormatterMediumStyle];
[dateformater setTimeStyle:NSDateFormatterShortStyle];
NSString *string_date=[dateformater stringFromDate:date];
NSLog(@"Loacle:----%@ Date:----%@",[[NSLocale currentLocale] localeIdentifier],string_date);
下面是本地化日期是什麼樣子一些例子,這裏是出了問題。
Loacle:----da_DK Date:----24/11/2011 14.10--------(WRONG)
Loacle:----en_BE Date:----24 Nov 2011 14:09--------(OK)
Loacle:----nl_BE Date:----24-nov.-2011 14:10------(WRONG)
Loacle:----fr_BE Date:----24 nov. 2011 14:11-------(OK)
Loacle:----en_US Date:----Nov 24, 2011 2:11 PM-----(OK)
Loacle:----en_GB Date:----24 Nov 2011 14:11--------(OK)
要求說明它應該對所有區域一致。
解釋爲什麼「錯誤」行是錯誤的。 – vocaro
我想一致的方式爲loacale en_BE我沒有得到分隔符和獲得月份符號,但da_DK我越來越分隔符在日期和我越來越11而不是11月 – Narayana