javaandroidtime

How to get the current Time


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

Solution

  • int hours = new Time(System.currentTimeMillis()).getHours();