Java TimeUnit Usage getTimeFormat(final long time)

Here you can find the source of getTimeFormat(final long time)

Description

get Time Format

License

Open Source License

Declaration

public static String getTimeFormat(final long time) 

Method Source Code


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

import java.util.concurrent.TimeUnit;

public class Main {
    public static String getTimeFormat(final long time) {
        final String format = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(time),
                TimeUnit.MILLISECONDS.toMinutes(time) % TimeUnit.HOURS.toMinutes(1),
                TimeUnit.MILLISECONDS.toSeconds(time) % TimeUnit.MINUTES.toSeconds(1));
        return time < 3600000 ? format.substring(3) : format;
    }/*from  ww w  .  j  a v a  2 s  . co  m*/
}

Related

  1. getSecondsDateDiff(Date dateStart)
  2. getSecondsTimeStamp()
  3. getTime()
  4. getTimeComparisonEpsilonMicros()
  5. getTimeDifference(Date startDate, Date endDate)
  6. getTimeForS3URL()
  7. getTimeInMillis(String str)
  8. getTimeString(long millis)
  9. getTimezoneOffset(TimeZone timeZone)