How to get the current Time

前端 未结 7 2072
陌清茗
陌清茗 2021-01-04 11:28

How to get the current time in Android?

When i use

int hours = java.sql.Time.this.getHours();

i get the error:

No          


        
相关标签:
7条回答
  • 2021-01-04 12:14

    If you just want the current timestamp, you can use:

    long millis = System.currentTimeMillis()
    

    You can also get other time related values such as the uptime or total elapsed time since the last boot (including sleep time) from android.os.SystemClock.

    0 讨论(0)
提交回复
热议问题