Java API Tutorial - Java TimeUnit.toHours(long duration)








Syntax

TimeUnit.toHours(long duration) has the following syntax.

public long toHours(long duration)

Example

In the following code shows how to use TimeUnit.toHours(long duration) method.

import java.util.concurrent.TimeUnit;
//from   www.j a v  a  2s .co  m
public class Main {
  public static void main(String[] args) {
    TimeUnit tu = TimeUnit.DAYS;

    System.out.println(tu.toDays(1));
    System.out.println(tu.toHours(1));
    System.out.println(tu.toMinutes(1));

  }
}

The code above generates the following result.