Here you can find the source of durationToString(long durationInMillisLong)
public static String durationToString(long durationInMillisLong)
//package com.java2s; //License from project: Open Source License public class Main { public static String durationToString(long durationInMillisLong) { double durationInMillis = (double) durationInMillisLong; return durationToString(durationInMillis); }//from w w w.j av a 2 s .c o m public static String durationToString(double durationInMillis) { if (durationInMillis < 1000) { return String.format("%.3f ms", durationInMillis); } double durationInSecs = durationInMillis / 1000; if (durationInSecs < 60) { return String.format("%.3f sec", durationInSecs); } double durationInMins = durationInSecs / 60; if (durationInMins < 60) { return String.format("%.3f mins", durationInMins); } double durationInHours = durationInMins / 60; return String.format("%.3f hours", durationInHours); } }