8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

NSLocaleIdentifier とカレンダーの暦設定

Last updated at Posted at 2013-03-18

NSLocale を使うと iOS 端末の書式(地域)設定、よくある ja_JP とかの ISO_639 のやつを取得できる。

NSString *localeID = [[NSLocale currentLocale] objectForKey:NSLocaleIdentifier];

カレンダーが「西暦」で各書式設定を取得:

  • ja_JP (日本、西暦)
  • en_US (アメリカ合衆国、西暦)
  • ru_UA (ウクライナ、西暦)
  • zh_TW (台湾、西暦)

「和暦」だとこうなる:

  • ja_JP@calendar=japanese (日本、和暦)
  • en_US@calendar=japanese (アメリカ合衆国、和暦)

「タイ仏暦」だとこうなる:

  • ja_JP@calendar=buddhist (日本、タイ仏暦)
  • en_US@calendar=buddhist (アメリカ合衆国、タイ仏暦)

西暦の場合はデフォルトということなのか、"@calendar=gregorian" とはならない。

他にも通貨だったりいろいろ拡張記法があるらしい。
http://userguide.icu-project.org/locale

8
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?