Java TimeUnit Usage millisToHMSms(long millis)

Here you can find the source of millisToHMSms(long millis)

Description

millis To HM Sms

License

Open Source License

Declaration

public static String millisToHMSms(long millis) 

Method Source Code

//package com.java2s;
import java.util.concurrent.TimeUnit;

public class Main {
    public static String millisToHMSms(long millis) {
        long hour = TimeUnit.MILLISECONDS.toHours(millis);
        long in1 = millis - TimeUnit.HOURS.toMillis(hour);
        long minute = TimeUnit.MILLISECONDS.toMinutes(in1);
        long in2 = in1 - TimeUnit.MINUTES.toMillis(minute);
        long second = TimeUnit.MILLISECONDS.toSeconds(in2);
        long in3 = in2 - TimeUnit.SECONDS.toMillis(second);

        return String.format("%dh:%dm:%ds:%dms", hour, minute, second, in3);
    }//from  w  ww .j av a2  s.  c  om
}

Related

  1. mergeResults(List>> futures)
  2. millisBetweenNanoTimes(long startNanos, long endNanos)
  3. millisecondsToHumanReadable(long duration)
  4. millisElapsedSince(long startNanoTime)
  5. millisToDays(long millisLocal)
  6. millisToReadableTime(long milliseconds)
  7. millisToString(double millis)
  8. millisToString(long millis)
  9. millisToString(long ms)