Lightster Lightster - 8 months ago 45
Android Question

How can I get the hour of the day from milliseconds in Android

I was looking for the answer on the web but no one answers exactly what I want. Say I have a milliseconds from epoch,

. I need to know the hour of the day of said millis, just the hour, from 00 to 24, ideally not as a string, but as an int.

Is there a easy way to achieve this. Currently I'm using
to get the string with
, but I'm sure there must be a better practice.

Thanks beforehand

Answer Source
Calendar time = Calendar.getInstance();