How to get the current time in Android?
When i use
int hours = java.sql.Time.this.getHours();
i get the error:
No enclosing instance of the type Time is accessible in scope
How to get the current time in Android?
When i use
int hours = java.sql.Time.this.getHours();
i get the error:
No enclosing instance of the type Time is accessible in scope
The an instance of the Calendar
Class is set to the current date and time.
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
.