List of utility methods to do Time Readable Format
String | toTimeExpression(long ms, int frames) to Time Expression String minus = ms >= 0 ? "" : "-"; ms = Math.abs(ms); long hours = ms / 1000 / 60 / 60; ms -= hours * 1000 * 60 * 60; long minutes = ms / 1000 / 60; ms -= minutes * 1000 * 60; long seconds = ms / 1000; ms -= seconds * 1000; ... |
String | toTimeFormat(String _srcTime) to Time Format if (_srcTime == null || _srcTime.length() != 4) return _srcTime; return _srcTime.substring(0, 2) + ":" + _srcTime.substring(2, 4); |
String | toTimeHumanReadable(final long time) Convert a number of milliseconds into a human reading string. long min = time / (60 * 1000); long minRest = time % (60 * 1000); long sec = minRest / 1000; long mili = minRest % 1000; return String.format("%02d:%02d.%03d", min, sec, mili); |
String | toTimeSpanDescription(long time) to Time Span Description int days = (int) (time / DAY_MS); time -= days * DAY_MS; int hours = (int) (time / HOUR_MS); time -= hours * HOUR_MS; int minutes = (int) (time / MINUTE_MS); time -= minutes * MINUTE_MS; int seconds = (int) (time / SECOND_MS); time -= seconds * SECOND_MS; ... |
String | toTimestamp(long time) PostgreSQL to_timestamp() doesn't support timezone specifications, so this is the only way how to set correct timestamp with timezone using string (as our current DAOs uses only strings to create SQL). return String.format("to_timestamp(%d::double precision / 1000)", time); |
String | toTimeStampString(String timeStr) to Time Stamp String String result = ""; result += timeStr.substring(0, 4); result += "-"; result += timeStr.substring(4, 6); result += "-"; result += timeStr.substring(6, 8); if (timeStr.length() > 8) { result += " " + timeStr.substring(8, 10); ... |
String | toTimeString(double millis) to Time String double display = millis; if (display < 1000) return display + "ms"; display /= 1000.0; if (display < 60) return String.format("%-2.2f", display) + "s"; display /= 60; if (display < 60) ... |
String | toTimeString(long frame) to Time String long hour = (long) (frame / (60 * 60 * 1000)); long remain = (long) (frame % (60 * 60 * 1000)); long minute = remain / (60 * 1000); remain = remain % (60 * 1000); long second = remain / 1000; remain = remain % 1000; String result = ""; if (hour < 10) { ... |
String | toTimeString(long millis) to Time String int ms = (int) (millis % 1000); int sec = (int) (Math.floor(millis / 1000)) % 60; int min = (int) (Math.floor(millis / (1000 * 60))) % 60; int hours = (int) (Math.floor(millis / (1000 * 60 * 60))) % 24; int days = (int) (Math.floor(millis / (1000 * 60 * 60 * 24))); StringBuilder sb = new StringBuilder(); if (days > 0) { sb.append(days).append("d"); ... |
String | toTimeString(long millis, boolean showSeconds, String separatorHours, String separatorMin, String separatorSec) To time string string. int h = (int) (millis / 1000) / 3600; int m = (int) (millis / 1000) % 3600 / 60; int s = (int) (millis / 1000) % 60; if (h == 0 && m == 0) { if (!showSeconds) return "0min"; else return "0s"; ... |