Java TimeUnit convert milliseconds to hours

Description

Java TimeUnit convert milliseconds to hours

import java.util.concurrent.TimeUnit;

public class Main {

  public static void main(String[] args) {

    long mill = 9999999999L;
    // Convert to hours
    long hours = TimeUnit.MILLISECONDS.toHours(mill);
    System.out.println(hours);/*from   w w w  . j av a2  s  . c  om*/
    // Convert to days
    Long days = TimeUnit.HOURS.toDays(hours);
    System.out.println(days);
    
    long minutes = TimeUnit.MILLISECONDS.toMinutes(mill);
    
    System.out.println(minutes);

  }
}



PreviousNext

Related