0
3

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.

【swift 5】 dateFormat の多言語対応

Last updated at Posted at 2020-05-24

アプリを多言語対応する時に、年月日の表示を国別に変える必要があります。
日本人が使う時は、2020年5月24日
アメリカ人が使う時は、May 24, 2020
と表示させるには以下のようにします。

let formatter = DateFormatter()
formatter.dateFormat = DateFormatter.dateFormat(fromTemplate: "ydMMM", options: 0, locale: .autoupdatingCurrent)

locale: .autoupdatingCurrent とすることでユーザーが選んだ「使用する言語の優先順序」第一位の言語が選択されます。

0
3
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
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?