Java Utililty Methods Second Convert

List of utility methods to do Second Convert

Description

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

Method

StringtoHhMmSs(long seconds)
to Hh Mm Ss
DecimalFormat f = new DecimalFormat("00");
long h = seconds / 3600;
long m = (seconds % 3600) / 60;
long s = seconds % 60;
return f.format(h) + ":" + f.format(m) + ":" + f.format(s);
longtoNanoseconds(long sec, long nanos)
to Nanoseconds
long result = nanos;
result = result + 1000000000 * sec;
return result;
StringtoSeconds(double value)
to Seconds
return String.format("%6.3fB", value);
longtoSeconds(long date)
to Seconds
return date / 1000L;
StringtoSeconds(long millis)
to Seconds
return toString(millis, "s");
longtoSeconds(long milliseconds)
This method strips milliseconds and returns seconds.
return milliseconds / 1000;
doubletoSeconds(long nanoseconds)
Converts nanoseconds to seconds
return toSeconds((double) nanoseconds);
DoubletoSeconds(long nanoSeconds)
to Seconds
return nanoSeconds / SECONDS;
longtoSecondsPrecisionInMs(long ms)
Reduces the precision of a time in milliseconds to seconds precision.
return ms - (ms % 1000);
StringtoTimeStringNoSeconds(Date timeString)
to Time String No Seconds
return toDateString(timeString, "HH:mm");