List of utility methods to do Second Convert
String | convertSecondsToTime(int seconds) Converts the given seconds to a time format with following format: days:hours:minutes:seconds. StringBuffer buffer = new StringBuffer(); int days = seconds / 86400; int hours = (seconds / 3600) % 24; int minutes = (seconds / 60) % 60; int secs = seconds % 60; if (days > 0) buffer.append(Integer.toString(days)); ... |
String | convertSecondsToTime(int totalSecs) convert Seconds To Time int hours = totalSecs / 3600; int minutes = (totalSecs % 3600) / 60; int seconds = totalSecs % 60; return (hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds; |
String | convertSecondsToTimecode(float totalSeconds) Convert the given number of seconds into a timecode string of the form "HH:mm:ss.SSS" return convertSecondsToTimecode(totalSeconds, 3);
|
int[] | convertSecondsToTimeUnits(int seconds) convert Seconds To Time Units int[] timeUnits = new int[4]; int remnant = seconds; if (remnant >= DAY) { timeUnits[0] = remnant / DAY; remnant = remnant % DAY; if (remnant >= HOUR) { timeUnits[1] = remnant / HOUR; ... |
float | convertTimecodeToSeconds(String timecode) Converts the given timecode string of the form "HH:mm:ss[.SSS]" to the total number of seconds it represents String[] timeParts = timecode.split(":"); int hours = Integer.parseInt(timeParts[0]); int minutes = Integer.parseInt(timeParts[1]); float seconds = Float.parseFloat(timeParts[2]) + (60 * minutes) + (60 * 60 * hours); return seconds; |
long | convertTimemilisecondsToHours(long time) convert Timemiliseconds To Hours long hours = 0; hours = time / (60 * 60 * 1000); return hours; |
String | convertTimeSecondsToHMS(long longSecs) Method to converts time given in seconds to string representation in days, hours, minutes and seconds long days = longSecs / (60 * 60 * 24); long remainder = longSecs % (60 * 60 * 24); long hours = remainder / (60 * 60); remainder = remainder % (60 * 60); long mins = remainder / (60); remainder = remainder % (60); long secs = remainder; String strDaysHrsMinsSecs = ""; ... |
int | convertTimeToSeconds(String a_time) convert Time To Seconds int secSinceMidnight = 0; int hours, minutes, seconds; String[] splitTime = a_time.split(":"); hours = Integer.parseInt(splitTime[0]); minutes = Integer.parseInt(splitTime[1]); seconds = Integer.parseInt(splitTime[2]); secSinceMidnight = (3600 * hours) + (60 * minutes) + seconds; return secSinceMidnight; ... |
long | convertToSeconds(String time) convert To Seconds time = time.toLowerCase(); long seconds = 0; int index = 0; if (!(time.contains("s") || time.contains("m") || time.contains("h") || time.contains("d") || time.contains("w") || time.contains("y"))) { return -1; while (!time.equals("")) { ... |
float | convertToSeconds(String timeStr) convert To Seconds String[] partsStr = unpack(timeStr, ":"); float[] partsFl = new float[partsStr.length]; for (int i = 0; i < partsFl.length; i++) { try { partsFl[i] = Float.valueOf(partsStr[i]).floatValue(); } catch (NumberFormatException e) { partsFl[i] = 0; float totalSeconds = partsFl[partsFl.length - 1]; if (partsFl.length > 1) { totalSeconds += 60 * (partsFl[partsFl.length - 2]); if (partsFl.length > 2) { totalSeconds += 3600 * (partsFl[partsFl.length - 3]); return totalSeconds; |