objective c - iOS: Internalization the Japanese date format to show Heisei Calendar -
i developing ios application support english , japanese language.
i want show date's japanese calendar type(heisei).
instead of showing english year 2013, want show heisei year 25.
january 5, 25 heisei (region format: u.s., calendar: japanese, language: english) 平成25年1月5日 (region format: japan, calendar: japanese, language: english)
note: unable see heisei in ios calendar when change calendar type japanese.
use date formatters , locales. if want "january 5, 25 heisei" format, that's locale identifier of en_us@calendar=japanese
. identifier "平成25年1月5日" ja_jp@calendar=japanese
.
this code illustrates use of both convert "january 5, 25 heisei" string nsdate
, , convert nsdate
string in form of "平成25年1月5日".
nsdateformatter *formatter = [[nsdateformatter alloc] init]; formatter.locale = [[nslocale alloc] initwithlocaleidentifier:@"en_us@calendar=japanese"]; formatter.datestyle = nsdateformatterlongstyle; nsdate *date = [formatter datefromstring:@"january 5, 25 heisei"]; formatter.locale = [[nslocale alloc] initwithlocaleidentifier:@"ja_jp@calendar=japanese"]; nsstring *string = [formatter stringfromdate:date];
Comments
Post a Comment