Here you can find the source of formatTimeInMilisec(long time)
public static String formatTimeInMilisec(long time)
//package com.java2s; public class Main { public static String formatTimeInMilisec(long time) { if (time / 1000 < 1) { return "0 seconds"; }//from w w w. j av a 2 s. c o m long inMinutes = time / 60000; long hours = inMinutes / 60; String formatedTime = ""; if (hours > 0) { String unit = hours > 1 ? "hours" : "hour"; formatedTime = hours + " " + unit; } long minutes = inMinutes - hours * 60; if (minutes > 0) { String unit = minutes > 1 ? "minutes" : "minute"; formatedTime = formatedTime + " " + minutes + " " + unit; } long seconds = (time / 1000) - minutes * 60 - hours * 60 * 60; if (seconds > 0) { String unit = minutes > 1 ? "seconds" : "second"; formatedTime = formatedTime + " " + seconds + " " + unit; } return formatedTime; } }