Here you can find the source of convertMillis(long millis)
Parameter | Description |
---|---|
millis | the milli-seconds to convert |
public static String convertMillis(long millis)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.TimeUnit; public class Main { /**//from w ww . j a v a2 s . c o m * Converts the milli-seconds long into a string. * * @param millis the milli-seconds to convert * @return a string representation of the long value */ public static String convertMillis(long millis) { String result; if (TimeUnit.MILLISECONDS.toHours(millis) != 0L) { result = String.format("%d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(millis), TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)), TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))); } else { result = String.format("%d:%02d", TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)), TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))); } return result; } }