Here you can find the source of formatMilliSecondsHumanReadable(long x)
public static String formatMilliSecondsHumanReadable(long x)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatMilliSecondsHumanReadable(long x) { @SuppressWarnings("unused") long millis = 0; long seconds = 0; long minutes = 0; long hours = 0; long days = 0; seconds = (int) (x / 1000); millis = x % 1000;//from ww w.ja va 2 s .c o m minutes = (int) (seconds / 60); seconds = seconds % 60; hours = (int) (minutes / 60); hours = hours % 60; days = (int) (hours / 24); days = days % 24; String str = seconds + "s"; /* * if (millis >= 100) str += "." + millis; else if (millis >= 10) str += * ".0" + millis; else if (millis >= 1) str += ".00" + millis; str += * " seconds"; */ if (minutes > 0) str = minutes + "m " + str; if (hours > 0) str = hours + "h " + str; if (days > 0) str = days + "d " + str; return str; } }