List of utility methods to do Second Format
String | formatTime(int second) format Time int hh = second / 3600; int mm = second % 3600 / 60; int ss = second % 60; if (0 != hh) { return String .format(Locale.CHINA, "%02d:%02d:%02d", hh, mm, ss); } else { return String.format(Locale.CHINA, "%02d:%02d", mm, ss); ... |
String | formatTime(int second) format Time int hh = second / 3600; int mm = second % 3600 / 60; int ss = second % 60; if (0 != hh) { return String.format("%02d:%02d:%02d", hh, mm, ss); } else { return String.format("%02d:%02d", mm, ss); |
String | formatIntoHHMMSS(int secsIn) format Into HHMMSS int hours = secsIn / 3600, remainder = secsIn % 3600, minutes = remainder / 60, seconds = remainder % 60; return ((hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds); |
String | getTimeFormattedFromSeconds(int seconds) Returns a formatted time string in the form of (hh:)mm:ss generated from seconds return getTimeFormattedFromMillis(seconds * 1000);
|
String | formatElapsedTime(long elapsedSeconds) Formats an elapsed time in the form "MM:SS" or "H:MM:SS" for display on the call-in-progress screen. return formatElapsedTime(null, elapsedSeconds);
|
String | formatElapsedTime(StringBuilder recycle, long elapsedSeconds) Formats an elapsed time in the form "MM:SS" or "H:MM:SS" for display on the call-in-progress screen. initFormatStrings(); long hours = 0; long minutes = 0; long seconds = 0; if (elapsedSeconds >= 3600) { hours = elapsedSeconds / 3600; elapsedSeconds -= hours * 3600; if (elapsedSeconds >= 60) { minutes = elapsedSeconds / 60; elapsedSeconds -= minutes * 60; seconds = elapsedSeconds; String result; if (hours > 0) { return formatElapsedTime(recycle, sElapsedFormatHMMSS, hours, minutes, seconds); } else { return formatElapsedTime(recycle, sElapsedFormatMMSS, minutes, seconds); |
String | formatElapsedTime(StringBuilder recycle, String format, long minutes, long seconds) Fast formatting of m:ss if (FAST_FORMAT_MMSS.equals(format)) { StringBuilder sb = recycle; if (sb == null) { sb = new StringBuilder(8); } else { sb.setLength(0); if (minutes < 10) { ... |
long | currentSeconds() current Seconds Calendar c = Calendar.getInstance(); long mseconds = c.getTimeInMillis(); return mseconds / 1000; |
long | getInXSeconds(int seconds) get In X Seconds return System.currentTimeMillis() + seconds * 1000;
|
String | toReadableTime(Context aContext, int aSeconds, boolean aShowSeconds) Converts time in seconds to the readable time StringBuilder builder = new StringBuilder(); if (aSeconds > DAY) { int days = aSeconds / DAY; String format = aContext.getResources().getString( R.string.utils_days, days); builder.append(format); builder.append(", "); aSeconds -= DAY * days; ... |