Here you can find the source of formatDuration(long milliseconds)
Parameter | Description |
---|---|
milliseconds | Time duration in milliseconds |
public static String formatDuration(long milliseconds)
//package com.java2s; /* Please see the license information at the end of this file. */ public class Main { /** Format a time duration as "hh:mm:ss" *//w ww . ja v a 2s. co m * @param milliseconds Time duration in milliseconds * * @return Formated time duration. */ public static String formatDuration(long milliseconds) { long seconds = milliseconds / 1000; long hours = seconds / 3600; seconds -= hours * 3600; long minutes = seconds / 60; seconds -= minutes * 60; return (hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds; } }