List of utility methods to do Time Format
String | formatTime(double totalTime) format Time if (totalTime > 60) { double mins = totalTime / 60; int secs = (int) totalTime % 60; if (mins > 60) { int hors = (int) (mins / 60); mins = mins % 60; int m = (int) mins; if (secs == 0) { ... |
String | formatTime(final int timeSec) format Time int s = timeSec; int m = s / 60; s -= (m * 60); return String.format("%02d:%02d", m, s); |
String | formatTime(final long time) format Time long seconds = time / 1000; final long hours = seconds / 3600; final long minutes = (seconds % 3600) / 60; seconds = seconds % 60; final StringBuilder sb = new StringBuilder(); if (hours != 0) { sb.append(hours).append(" hours "); if (minutes != 0) { sb.append(minutes).append(" minutes "); if (seconds != 0) { sb.append(seconds).append(" seconds"); return sb.toString(); |
String | formatTime(final long time) Formats time from long to a readable String final int hours = (int) ((time / 1000 + 8) % 24); final int minutes = (int) (60 * (time % 1000) / 1000); return String.format("%02d:%02d (%d:%02d %s)", hours, minutes, hours % 12 == 0 ? 12 : hours % 12, minutes, hours < 12 ? "am" : "pm"); |
String | formatTime(final long timeMS) Formats the time in ms to days, hours... long remaining = timeMS / 1000; int seconds = (int) remaining % 60; remaining = remaining / 60; int minutes = (int) remaining % 60; remaining = remaining / 60; int hours = (int) remaining % 24; int days = (int) remaining / 24; StringBuffer buffer = new StringBuffer(); ... |
String | formatTime(float seconds) format Time int s = (int) (seconds % 60); int ms = (int) (seconds % 1 * 100); int m = (int) (seconds / 60); if (m > 0) { return String.format("%d:%d.%d", m, s, ms); return String.format("%d.%d", s, ms); |
String | formatTime(int minutes) format Time String time = ""; int hours = minutes / 60; if (hours > 0) { int days = hours / 24; if (days > 0) { time += days + "d "; time += (hours % 24) + "h "; ... |
String | formatTime(int minutes) format Time int hours = minutes / 60; minutes -= hours * 60; if (hours == 0) { if (minutes == 0) { return "Saved recently"; } else if (minutes == 1) { return "Saved 1 minute ago"; } else { ... |
String | formatTime(int originalTime) format Time int time = originalTime; int hours = (time - time % (60 * 60)) / 60 / 60; String hS = "" + hours; if (hours < 10) hS = "0" + hours; time = time - (hours * 60 * 60); int minutes = (time - time % 60) / 60; String mS = "" + minutes; ... |
String | formatTime(int seconds) format Time if (seconds < 0) { return "not set"; int hours = seconds / 3600; int remainder = seconds % 3600; int minutes = remainder / 60; seconds = remainder % 60; return String.format("%02d:%02d:%02d", hours, minutes, seconds); ... |