TimeUnit toHours() method in Java with Examples
The toHours() method of TimeUnit Class is used to get the time represented by the TimeUnit object, as the number of Hours, since midnight UTC on the 1st January 1970.
public long toHours(long duration)
Parameters: This method accepts a mandatory parameter duration which is the duration in milliSeconds.
Return Value: This method returns the converted duration as Hours.
Below programt illustrate the implementation of TimeUnit toHours() method:
Time 1539585595812 milliSeconds in Hours = 427662
Time 1539585598692 milliSeconds in Hours = 427662