Java TimeUnit Usage formatMillis(long millis)

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

Description

format Millis

License

LGPL

Declaration

public static String formatMillis(long millis) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.concurrent.TimeUnit;

public class Main {
    public static String formatMillis(long millis) {
        return String.format("%dd:%dh:%dm:%ds:%dms", TimeUnit.MILLISECONDS.toDays(millis),
                TimeUnit.MILLISECONDS.toHours(millis) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(millis)),
                TimeUnit.MILLISECONDS.toMinutes(millis)
                        - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
                TimeUnit.MILLISECONDS.toSeconds(millis)
                        - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)),
                millis - TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(millis)));
    }//  w w w  .ja v  a 2 s  .c o  m
}

Related

  1. formatElapsedTime(long elapsedTimeMs)
  2. formatElapsedTime(long millis)
  3. formatInterval(final long l)
  4. formatMillis(final long millis)
  5. formatMillis(final long millis)
  6. formatMillis(long millis)
  7. formatMillisecs(long lMillisecs, final boolean bWantMSecs)
  8. formatMillisIntoMinutesAndSeconds(long millis)
  9. formatMs(long millis)