How to get the current time in Android?
When i use
int hours = java.sql.Time.this.getHours();
i get the error:
No
Calendar cal = Calendar.getInstance(); // get current time in a Calendar
then you can do lots with the Calendar instance, such as get the Hours or the Minutes - like:
int hour = cal.get(Calendar.HOUR_OF_DAY);
This is recommended when you have to localize to many locales, and print data in multiple formats, or do operations on dates.