Before Java 8 the common method was the Calendar
API:
Calendar cal = Calendar.getInstance();
int hour = cal.get(Calendar.HOUR_OF_DAY);
How can I get the current hour, but using the new Date-Time API provided in Java 8?
javajava-8java-time
Before Java 8 the common method was the Calendar
API:
Calendar cal = Calendar.getInstance();
int hour = cal.get(Calendar.HOUR_OF_DAY);
How can I get the current hour, but using the new Date-Time API provided in Java 8?
Best Answer
This all depends, but something like...
Should work just fine...
Take a closer look at
LocalTime#getHour
for more details