Java TimeUnit Usage getFormattedTimeForMS(Long timeInMillis)

Here you can find the source of getFormattedTimeForMS(Long timeInMillis)

Description

get Formatted Time For MS

License

Open Source License

Declaration

public static String getFormattedTimeForMS(Long timeInMillis) 

Method Source Code


//package com.java2s;

import java.util.concurrent.TimeUnit;

public class Main {
    public static String getFormattedTimeForMS(Long timeInMillis) {
        TimeUnit timeunit = TimeUnit.MILLISECONDS;
        long hours = timeunit.toHours(timeInMillis);
        long minutes = timeunit.toMinutes(timeInMillis) - TimeUnit.HOURS.toMinutes(hours);
        long seconds = timeunit.toSeconds(timeInMillis) - TimeUnit.HOURS.toSeconds(hours)
                - TimeUnit.MINUTES.toSeconds(minutes);
        return ((hours < 10) ? "0" + hours : hours) + ":" + ((minutes < 10) ? "0" + minutes : minutes) + ":"
                + ((seconds < 10) ? "0" + seconds : seconds);
    }//from w ww.j  a va2 s.  c  o m
}

Related

  1. getElapsedTime(Date start, Date end)
  2. getElapsedTimeString(long elapsed)
  3. getETA(final long seconds)
  4. getFormattedDiffTime(long timeFirst, long timeLast)
  5. getFormattedTime(long timeleft)
  6. getFriendlyTime(long duration)
  7. getInsertionEndIndex(List list, Delayed key)
  8. getInStringSeconds(String pollInterval)
  9. getLastSlotDate(final int occurrences, final int periodicity, final long firstSlotDate, final int firstSlotDay, final String selectedDays)