List of utility methods to do Second Format
String | formatNanoseconds(final long ns) format Nanoseconds String s; final long NS_ONE_MICROSECOND = 1_000L; final long NS_ONE_MILLISECOND = 1_000L * NS_ONE_MICROSECOND; final long NS_ONE_SECOND = 1_000 * NS_ONE_MILLISECOND; final long NS_ONE_MINUTE = 60L * NS_ONE_SECOND; final long NS_ONE_HOUR = 60L * NS_ONE_MINUTE; final long NS_ONE_DAY = 24L * NS_ONE_HOUR; if (ns < NS_ONE_MICROSECOND) { ... |
String | formatSecondFractions(long numUnits, int denominator) format Second Fractions if (numUnits == 0) { return "0:00:00"; StringBuffer timeStr = new StringBuffer(10); long seconds = (numUnits / denominator) % 60; long minutes = (numUnits / denominator / 60) % 60; long hours = (numUnits / denominator / 60 / 60); timeStr.append(hours); ... |
String | formatSeconds(double seconds) format Seconds int i = (int) seconds; int s = i % 60; int m = i / 60; int min = m % 60; int h = m / 60; return (h > 0 ? fillZeros(h, 2) + ":" : "") + (m > 0 || h > 0 ? fillZeros(min, 2) + ":" : "") + fillZeros(s, 2) + "." + (seconds % 1 != 0 ? String.valueOf(seconds % 1).substring(2, 3) : "0"); |
String | formatSeconds(double seconds) Formats seconds in human readable form. StringBuilder result = new StringBuilder(); int minutes = (int) (seconds / 60); int digits = 1; if (seconds < 0.01) { digits = 6; } else if (seconds < 1) { digits = 3; seconds -= minutes * 60; if (minutes > 0) { result.append(minutes).append(" m "); result.append(String.format("%,." + digits + "f s", seconds)); return result.toString(); |
String | formatSeconds(double seconds, int precision) format Seconds int min = (int) ((Math.round(seconds)) / 60); int hrs = min / 60; if (min > 0) seconds -= min * 60; if (seconds < 0) seconds = 0; if (hrs > 0) min -= hrs * 60; ... |
String | formatSeconds(double value) format Seconds return String.format("%4.2f", value); |
String | formatSeconds(final int total) format Seconds final int minutes = (total / 60); final int seconds = (total % 60); String secs = Integer.toString(seconds); if (seconds < 10) { secs = "0" + seconds; final String time = minutes + ":" + secs; return time; ... |
String | formatSeconds(int seconds) Formats the specified amount of seconds to a short format. int hour = 0, min = 0; if (seconds >= 3600) { hour = seconds / 3600; seconds = seconds % 3600; if (seconds >= 60) { min = seconds / 60; seconds = seconds % 60; ... |
String | formatSeconds(int seconds) formats seconds into mm:ss format SimpleDateFormat format = new SimpleDateFormat("mm:ss"); return format.format(new Date((long) seconds * 1000)); |
String | formatSeconds(long dSeconds, boolean exact) format Seconds int iSeconds = (int) dSeconds; int seconds = iSeconds % 60; int minutes = iSeconds / 60 % 60; int hours = iSeconds / 3600 % 24; int days = iSeconds / 86400; String sSeconds = seconds + "s"; if (days == 0 && hours == 0 && minutes == 0) { return sSeconds; ... |