List of utility methods to do Time Readable Format
String | toTimeString(long seconds) to Time String long hours = seconds / 3600, remainder = seconds % 3600, minutes = remainder / 60, secs = remainder % 60; return ((hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (secs < 10 ? "0" : "") + secs); |
String | toTimeStringForceShowHours(long millis, boolean showSeconds, boolean showUnits) To time string force show hours string. int h = (int) (millis / 1000) / 3600; int m = (int) (millis / 1000) % 3600 / 60; int s = (int) (millis / 1000) % 60; if (!showUnits) return showSeconds ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", h, m); else return showSeconds ? String.format("%02dh %02dmin %02ds", h, m, s) : String.format("%02dh %02dmin", h, m); ... |