List of utility methods to do Second
boolean | timeElapsedSecond(long prevTime, long curTime, long periodSecond) time Elapsed Second long gap = periodSecond * 1000; if (curTime - prevTime >= gap) { return true; return false; |
String | timeFromSeconds(int timeInSec) Given the total number of seconds ,format the time into MM:SS where MM represents the number of minutes, SS represents the number of seconds. int min = timeInSec / 60; int sec = timeInSec % 60; StringBuffer time = new StringBuffer(); if (min < 10) { time.append("0"); time.append(min); time.append(":"); ... |
String | timeFromSeconds(long ms) time From Seconds StringBuilder sb = new StringBuilder(40); if (ms / 628992000 > 0) { long years = ms / 628992000; sb.append(years + (years == 1 ? " year " : " years ")); ms -= years * 628992000; if (ms / 2620800 > 0) { long months = ms / 2620800; ... |
long | timeSpanInSeconds(long time1, long time2) time Span In Seconds return (time2 - time1) / 1000;
|
double | timeStampSeconds() time Stamp Seconds return System.currentTimeMillis() * 1E-3;
|
int | timeStringToSeconds(String input) time String To Seconds int result = 0; String number = ""; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (Character.isDigit(c)) { number += c; } else if (Character.isLetter(c) && !number.isEmpty()) { result += convert(Integer.parseInt(number), c); ... |
int | timeStringToSeconds(String time) time String To Seconds int resultingTime = 0; String[] splitString = time.split("\\."); if (splitString.length == 0) splitString = time.split(":"); else splitString = splitString[0].split(":"); if (splitString.length == 3) { resultingTime += Integer.valueOf(splitString[0]) * 3600; ... |
int | timeToSeconds(String in) Convert a time String to seconds int secs; String[] n = in.split(":"); secs = 0; if (n.length == 3) { try { secs = Integer.parseInt(n[0]) * 3600 + Integer.parseInt(n[1]) * 60 + Integer.parseInt(n[2]); } catch (NumberFormatException e) { ; ... |
int | timeToSeconds(String textTime) Parses the message for time and returns it in seconds if (textTime.charAt(0) == ':') textTime = "0" + textTime; if (textTime.charAt(textTime.length() - 1) == ':') textTime = textTime + "0"; String[] parts = textTime.split(":"); int time = 0; try { if (parts.length == 3) { ... |
long | timeToSeconds(String time) time To Seconds String[] strs = time.split(":"); long seconds = Long.valueOf(strs[0]) * 60 * 60 * 1000 + Long.valueOf(strs[1]) * 60 * 1000 + Long.valueOf(strs[2]) * 1000; return seconds; |