Here you can find the source of formatSeconds(long dSeconds, boolean exact)
public static String formatSeconds(long dSeconds, boolean exact)
//package com.java2s; public class Main { public static String formatSeconds(long dSeconds, boolean exact) { int iSeconds = (int) dSeconds; int seconds = iSeconds % 60; int minutes = iSeconds / 60 % 60; int hours = iSeconds / 3600 % 24; int days = iSeconds / 86400; String sSeconds = seconds + "s"; if (days == 0 && hours == 0 && minutes == 0) { return sSeconds; }/*from w w w . j ava 2 s .c om*/ String sMinutes = minutes + "min " + sSeconds; if (days == 0 && hours == 0) { return sMinutes; } String sHours = hours + "h " + (exact ? sMinutes : minutes + "min "); if (days == 0) { return sHours; } return days + "d " + (exact ? sHours : hours + "h "); } }