Java Millisecond Convert getDurationBreakdown(long durationInMillis)

Here you can find the source of getDurationBreakdown(long durationInMillis)

Description

Convert a millisecond duration to a string format

License

Apache License

Parameter

Parameter Description
durationInMillis A duration to convert to a string form

Return

A string of the form "25:36:259".

Declaration

public static String getDurationBreakdown(long durationInMillis) 

Method Source Code


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

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    /**//from w w w.  j a  v  a 2s. c  om
     Convert a millisecond duration to a string format
        
     @param durationInMillis
     A duration to convert to a string form
        
     @return A string of the form "25:36:259".
     */
    public static String getDurationBreakdown(long durationInMillis) {
        if (durationInMillis < 0) {
            throw new IllegalArgumentException("Duration must be greater than zero!");
        }
        return (new SimpleDateFormat("mm:ss:SSS")).format(new Date(durationInMillis));
    }
}

Related

  1. convertTimeToDurationMilliseconds(String time)
  2. convertToMillis(float timeInSeconds)
  3. convertToMillis(String time)
  4. convertToMilliseconds(String value)
  5. getDuration(final long millis)
  6. getDurationMillisecond(Date date1, Date date2)
  7. getHumanDisplayForTimediff(Long diffMillis)
  8. getNice(long timeMillisecGMT)
  9. getStringFromMillis(long timestamp)