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

longsamples2millis(long samples, double sampleRate)
samplesmillis
return 0L;
intsamplesToMilliseconds(int sampleRate, int samples)
Calculates how many milliseconds samples are with sampleRate.
return Math.round((float) samples / sampleRate * 1000);
voidsetGlobalDebugMillis(int millis)
If global debug should be on or off.
globalDebugMillis = millis;
DatesetMilliseconds(Date date, int amount)
Sets the miliseconds field to a date returning a new object.
return set(date, Calendar.MILLISECOND, amount);
intsetMilliSecondsFromSeconds(int seconds)
used in the ListenerRegistryDAO the refresh_time in the DB is in second format.
int msecs = 600000; 
msecs = seconds * 1000;
return msecs;
voidsetThreadSleepTimeInMillis(long inThreadSleepTimeInMillis)
set Thread Sleep Time In Millis
threadSleepTimeInMillis = inThreadSleepTimeInMillis;
StringstripMillisFromJdbcTimestampString(String timestamp)
Strips off the millseconds value from a JDBC timestamp String returned from the MySQL JDBC connector.
if (null != timestamp) {
    if (timestamp.contains(".")) {
        return timestamp.substring(0, timestamp.lastIndexOf('.'));
    } else {
        return timestamp;
return null;
...
StringstripSubMillis(String iso8601string)
strip Sub Millis
if (iso8601string.length() < isoDateWithSubMsMin || iso8601string.length() > isoDateWithSubMsMax)
    return iso8601string;
String[] parts = splitOnFirst(iso8601string, '.');
String suffix = parts[1].substring(parts[1].length() - 6); 
String ms = parts[1].substring(0, 3);
return parts[0] + "." + ms + suffix;
StringstrMillis(final long ns)
str Millis
if (ns < 1000)
    return ns + " ms";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < MSTIMESET.length; i++) {
    if (ns >= MSTIMESET[i]) {
        long u = ns / MSTIMESET[i];
        sb.append(Long.toString(u));
        sb.append(MSSUFFIXES[i]);
...
StringstrMillisOLD(long dlt)
str Millis OLD
StringBuffer sb = new StringBuffer();
int millis = (int) (dlt % 1000); 
dlt /= 1000; 
boolean sp = false;
if (dlt >= DAYS) {
    sb.append(dlt / DAYS);
    sb.append("D");
    dlt %= DAYS;
...