Java Utililty Methods Millisecond Convert

List of utility methods to do Millisecond Convert

Description

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

Method

longmillisecsToSecs(long millisecs)
Converts millisecs to secs (Round down).
return millisecs / 1000;
StringmilliSecsToTime(double current, double max, double buffer)
milli Secs To Time
int currentSec = (int) (current / 1000);
int maxSec = (int) (max / 1000);
int bufPer = Math.min((int) ((buffer * 100) / max), 100);
return String.format("%3d:%02d /%3d:%02d [%3d%%]", Integer.valueOf(currentSec / 60),
        Integer.valueOf(currentSec % 60), Integer.valueOf(maxSec / 60), Integer.valueOf(maxSec % 60),
        Integer.valueOf(bufPer));
StringmilliSecToString(final long mS)
Returns the given time in milliseconds formatted as Hours:Min:Sec.mSec
final long rem_mS = (long) (mS % 1000.0);
final long rem_sec = (long) ((mS / 1000.0) % 60.0);
final long rem_min = (long) ((mS / 60000.0) % 60.0);
final long hr = (long) (mS / 3600000.0);
final String mSstr = zeroPad(Long.toString(rem_mS), 3);
final String secStr = zeroPad(Long.toString(rem_sec), 2);
final String minStr = zeroPad(Long.toString(rem_min), 2);
return String.format("%d:%2s:%2s.%3s", hr, minStr, secStr, mSstr);
...
StringmilliSecToTime(double millis)
milli Sec To Time
int sec = (int) (millis / 1000);
return String.format("%3d:%02d", Integer.valueOf(sec / 60), Integer.valueOf(sec % 60));
longmillisToCycles(double millis, double hz)
millis To Cycles
return (long) (hz * millis / 1000);
StringmillisToDateString(Long Millis)
millis To Date String
Date date = millisToDate(Millis);
return getFormat(datetimeFormat).format(date);
longmillisToDays(long millis)
millis To Days
return millis / 1000 / 60 / 60 / 24;
StringmillisToDuration(long millis)
millis To Duration
long seconds = millis / 1000;
if (seconds > 0) {
    millis -= seconds * 1000;
return seconds + "." + millis;
StringmillisToDurationString(long millis)
Given a number of milliseconds, product a string of the format
 7d6h6m.21s 
StringBuilder sb = new StringBuilder();
if (millis < 0) {
    sb.append('-');
    millis = -(millis);
long val = millis / 86400000L;
if (val > 0L) {
    sb.append(val).append('d');
...
StringmillisToHMS(long millis)
millis To HMS
boolean minus = false;
if (millis < 0) {
    minus = true;
    millis = -millis;
long s = millis / 1000;
long m = s / 60;
long h = m / 60;
...