Java Utililty Methods Millisecond Format

List of utility methods to do Millisecond Format

Description

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

Method

longmillis2samples(long ms, double sampleRate)
millissamples
return 0L;
longmillis2seconds(long millis)
millisseconds
return millis / 1000;
Stringmillis2String(long n)
Covert milliseconds to a String.
if (n < 0)
    return "-" + millis2String(-n);
else if (n < 1000)
    return n + "ms";
final StringBuilder b = new StringBuilder();
final int millis = (int) (n % 1000L);
if (millis != 0)
    b.append(String.format(".%03d", millis));
...
longmillisAsTicks(int ms)
millis As Ticks
return ms / 50;
Stringmilliseconds2String(long millis)
milliseconds String
long aux = millis / 1000;
int minutes = (int) aux / 60;
aux = aux % 60;
return minutes + ":" + (aux < 10 ? "0" : "") + aux;
intmillisecondsPerTick(final int tps)
Change tps to number of milliseconds per tick, 1000/tps.
return 1000 / tps;
longmilliSecondsSince(long startMillis)
Milliseconds since a previous System#currentTimeMillis() call.
return (System.currentTimeMillis() - startMillis);
StringmilliSecondsToFormatedString(long timeMillis)
milli Seconds To Formated String
double time = timeMillis / 1000.0;
String tt = "";
if (time < 60)
    tt = new Double(time).doubleValue() + " s";
else if ((time / 60.0) < 60) {
    long mi = (long) (time / 60.0);
    long sec = (long) (time % 60.0);
    tt = mi + "m " + ((sec < 10) ? "0" : "") + sec + "s";
...
StringmillisecondsToToTimeFormat(long inMs)
milliseconds To To Time Format
long second = (inMs / 1000) % 60;
long minute = (inMs / (1000 * 60)) % 60;
long hour = (inMs / (1000 * 60 * 60)) % 24;
return String.format("%d:%02d:%02d", hour, minute, second);
long[]milliSekundsToTime(long millisecond)
milli Sekunds To Time
long[] date = new long[4];
long oneDay = 24 * 60 * 60 * 1000;
long oneHour = 60 * 60 * 1000;
long oneMinute = 60 * 1000;
long oneSecond = 1000;
date[0] = Math.abs(millisecond / oneDay);
millisecond -= (date[0] * oneDay);
date[1] = Math.abs(millisecond / oneHour);
...