Here you can find the source of millisToTimeSpan(long millis)
public static String millisToTimeSpan(long millis)
//package com.java2s; //License from project: Creative Commons License public class Main { public static String millisToTimeSpan(long millis) { if (millis < 60 * 1000) { long unit = roundUp(millis / 1000); return unit + (unit == 1 ? " second" : " seconds"); } else if (millis < 60 * 1000 * 60) { long unit = roundUp(millis / 60000); return unit + (unit == 1 ? " minute" : " minutes"); } else if (millis < 60 * 1000 * 60 * 24) { long unit = roundUp(millis / (60000 * 60)); return unit + (unit == 1 ? " hour" : " hours"); } else {// www. j a v a2 s.c o m long unit = roundUp(millis / (60000 * 60 * 24)); return unit + (unit == 1 ? " day" : " days"); } } private static long roundUp(double d) { return Math.round(d * 10.0) / 10; } }