List of utility methods to do Millisecond Format
String | formatMillis(Long millis) format Millis long seconds = millis / 1000; long minutes = seconds / 60; long hours = minutes / 60; long days = hours / 24; return days + " days " + hours % 24 + " hours " + minutes % 60 + " min " + seconds % 60 + " sec"; |
String | formatMillis(long millis) Format ms interval to min/sec/ms boolean isMinutes = false; double instTime = millis; String suffix = "milliseconds"; if (instTime > (60 * 1000)) { suffix = "minutes"; instTime = instTime / (60 * 1000); isMinutes = true; } else if (instTime > 1000) { ... |
String | formatMillis(long millis) Returns a formatted string using the pattern hh:mm:ss. int hours = (int) (millis / (1000 * 60 * 60)); int minutes = (int) (millis / (1000 * 60)) % 60; int seconds = (int) (millis / 1000) % 60; StringBuilder sb = new StringBuilder(); if (hours > 0) { sb.append(hours); sb.append(':'); if (minutes < 10 && hours > 0) { sb.append(0); sb.append(minutes); sb.append(':'); if (seconds < 10) { sb.append(0); sb.append(seconds); return sb.toString(); |
String | formatMillis(long t) format Millis Date date = new Date(t); return formatDate(date); |
String | formatMillis(long time) format Millis return time + MILLIS;
|
String | formatMillis(long time, boolean showMillis) format Millis long millis = time - (1000 * (time / 1000)); time /= 1000; long seconds = time - (60 * (time / 60)); time /= 60; long minutes = time - (60 * (time / 60)); time /= 60; long hours = time; String res = hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds; ... |
String | formatMillis(long timeMillis) format Millis long timeSeconds = timeMillis / 1000; long days = timeSeconds / 60 / 60 / 24; long hours = timeSeconds / 60 / 60 % 24; long mins = timeSeconds / 60 % 60; long seconds = timeSeconds % 60; StringBuilder sb = new StringBuilder(); boolean hasDays = days > 0; boolean hasHours = hours > 0; ... |
String | formatMillis(String millisecond, String format) format Millis Date date; if (format == null || "".equals(format)) { format = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(format); if (millisecond != null && millisecond.matches("\\d+")) { date = new Date(Long.parseLong(millisecond)); return sdf.format(date); ... |
String | formatMillisAsNumber(long millis) format Millis As Number BigDecimal value = new BigDecimal(millis).divide(MILLIS_DIVISOR, 3, BigDecimal.ROUND_HALF_UP); return MILLIS_NUMBER_FORMAT.format(value); |
String | formatMillisAsShortHumanReadablePeriod(long millis) Format the given milliseconds as a human readable time period return formatMillisAsShortHumanReadablePeriod(millis, false);
|