Here you can find the source of formatDurationMills(long millis)
Parameter | Description |
---|---|
millis | the duration to format in milliseconds |
public static String formatDurationMills(long millis)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww. j a va 2s. c om * Returns a formated string representation of {@code millis}. Format: * HH:MM:SS. * * @param millis * the duration to format in milliseconds * @return a formated string representation of {@code millis} */ public static String formatDurationMills(long millis) { long seconds = millis / 1000; long absSeconds = Math.abs(seconds); String positive = String.format("%d:%02d:%02d.%03d", absSeconds / 3600, (absSeconds % 3600) / 60, absSeconds % 60, millis % 1000); return seconds < 0 ? "-" + positive : positive; } }