Java Utililty Methods Milliseconds

List of utility methods to do Milliseconds

Description

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

Method

longgetMilliSeconds(String input)
get Milli Seconds
if (input.toLowerCase().endsWith("h")) {
    return Long.parseLong(input.replace("h", "")) * 60 * 60 * 1000;
} else if (input.toLowerCase().endsWith("m")) {
    return Long.parseLong(input.replace("m", "")) * 60 * 1000;
} else if (input.toLowerCase().endsWith("d")) {
    return Long.parseLong(input.replace("d", "")) * 24 * 60 * 60 * 1000;
} else if (input.toLowerCase().endsWith("w")) {
    return Long.parseLong(input.replace("w", "")) * 7 * 24 * 60 * 60 * 1000;
...
longgetMilliseconds(String time)
get Milliseconds
int lastPos = time.length() - 1;
long t = Long.parseLong(time.substring(0, lastPos));
char c = time.charAt(lastPos);
switch (c) {
case 's':
    return t * MILLISECONDS;
case 'm':
    return t * SECONDS * MILLISECONDS;
...
longgetMilliseconds(String unixtime)
get Milliseconds
return Long.valueOf(unixtime) * 1000;
longgetMillisecondsFromTimeString(String timeString)
get Milliseconds From Time String
int minIndex = timeString.indexOf(':');
int min = Integer.parseInt(timeString.substring(0, minIndex).trim());
String secString = timeString.substring(minIndex + 1);
int secIndex = secString.indexOf(':');
if (secIndex == -1)
    secIndex = secString.length();
int sec = Integer.parseInt(secString.substring(0, secIndex).trim());
return (min * 60 + sec) * 1000L;
...
longgetMilliSecs()
get Milli Secs
return System.currentTimeMillis();
longgetMillisFromByteArray(byte[] buff, int offset)
Extracts an milliseconds from seconds strored in a byte array.
long result;
result = (buff[offset + 0] & 0x000000ff) | ((buff[offset + 1] & 0x000000ff) << 8)
        | ((buff[offset + 2] & 0x000000ff) << 16) | ((buff[offset + 3] & 0x000000ff) << 24);
result *= 1000L; 
return result;
longgetMillisPartFromNanos(long nanos)
getMillisPartFromNanos.
return nanos > 999999 ? nanos / ONE_MILLION : 0;
intgetMillisSinceInit()
get the number of milliseconds since first Util initialization
return (int) (System.currentTimeMillis() - initTime);
intgetNumSamplesForMillisAtSampleRate(final int sampleRate, final float millis)
get Num Samples For Millis At Sample Rate
return (int) getNumSamplesFloatForMillisAtSampleRate(sampleRate, millis);
doublegetOLEDateFromMillisRounded(long millis)
get OLE Date From Millis Rounded
return getOLEDateFromMillis(millis) + 1e-8;