LoginSignup
0
1

More than 3 years have passed since last update.

[Android]現在日時を取得する

Posted at

Android端末の現在日時を取得するコード

 //現在日時をyyyy/MM/dd HH:mm:ss形式で取得する

public static String getDate(){

    //取得する日時のフォーマットを指定
    final DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

    //時刻をミリ秒で取得
    final Date date = new Date(System.currentTimeMillis());

    //日時を指定したフォーマットで取得
    return df.format(date);
}

感想

めちゃくちゃ簡単なので、ぜひ試していただきたい。

参考URL

・Androidでの日時取得
https://qiita.com/zuccyi/items/d9c185588a5628837137

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