Here you can find the source of formatSeconds(long s, boolean letters)
public static String formatSeconds(long s, boolean letters)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatSeconds(long s, boolean letters) { String string = ""; if (s < 1) return "00:00"; long remainder; long days = (int) s / 86400; long hours = (int) (s % 86400) / 3600; remainder = s - days * 86400 - hours * 3600; long mins = (int) remainder / 60; long secs = remainder % 60; if (days > 0) { string += days;//from w w w . j a v a 2 s.co m if (letters) string += "d"; } if (hours > 0) { string += hours; if (letters) string += "h "; } if (mins < 10) string += "0" + mins + ":"; else string += mins + ":"; if (secs < 10) string += "0" + secs; else string += secs; return string; } }