0
1

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 3 years have passed since last update.

Android 日付を取得する方法

Last updated at Posted at 2020-11-08

Androidで日付を取得する方法を記録します。
思ったよりも簡単に書けました。

  fun getToday(): String {

         //表示させたい型を決める。 yは年、Mは月、dは日。
         //単位は自由に決められる。例えば、"yyyy/MM/dd"でもOK。
        val sdf = android.icu.text.SimpleDateFormat("yyyy年MM月dd日", Locale.JAPAN)
        
        //date型のインスタンスを作る。
        val date = Date()

        return sdf.format(date)
  }

以上です。

0
1
2

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?