Java TimeUnit Usage humanizeToTime(long millis)

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

Description

humanize To Time

License

Open Source License

Declaration

public static String humanizeToTime(long millis) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.TimeUnit;

public class Main {
    public static String humanizeToTime(long millis) {
        if (millis < 1000)
            return millis + " ms";

        if (millis < 1000 * 60)
            return TimeUnit.MILLISECONDS.toSeconds(millis) + " sec (" + millis + " ms)";

        else/*from  w  w w .  j av  a 2s .  co  m*/
            return String.format("%02d min, %02d sec (%d ms)", TimeUnit.MILLISECONDS.toMinutes(millis),
                    TimeUnit.MILLISECONDS.toSeconds(millis)
                            - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)),
                    millis);
    }
}

Related

  1. getTomorrowTimestamp()
  2. getUnit(long nanos)
  3. getValidityAsString(Date endDate)
  4. getWithTimeout(final Future future)
  5. humanizeTime(long hours, long minutes, long seconds)
  6. humanReadableDuration(Date from, Date to)
  7. humanReadableMillis(long millis)
  8. isCurrentDateBeforeAndWithinRangeOfDate( Date date, int rangeInDays)
  9. isTheSameDayCheckSummerTime(final Date day1, final Date day2, final boolean escapeYear)