Java Utililty Methods Second

List of utility methods to do Second

Description

The list of methods to do Second are organized into topic(s).

Method

booleantimeElapsedSecond(long prevTime, long curTime, long periodSecond)
time Elapsed Second
long gap = periodSecond * 1000;
if (curTime - prevTime >= gap) {
    return true;
return false;
StringtimeFromSeconds(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(":");
...
StringtimeFromSeconds(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;
...
longtimeSpanInSeconds(long time1, long time2)
time Span In Seconds
return (time2 - time1) / 1000;
doubletimeStampSeconds()
time Stamp Seconds
return System.currentTimeMillis() * 1E-3;
inttimeStringToSeconds(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);
...
inttimeStringToSeconds(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;
...
inttimeToSeconds(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) {
        ;
...
inttimeToSeconds(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) {
...
longtimeToSeconds(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;