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

StringgetDurationFromMillis(final long millis)
Given a number of milliseconds, calculates a duration string.
final long seconds = millis / 1000;
final long minutes = seconds / 60;
if (minutes == 0) {
    return seconds + "s ago";
final long hours = minutes / 60;
if (hours == 0) {
    return minutes + "m ago";
...
DoublegetDurationSecFromMillisDouble(long millis)
get Duration Sec From Millis Double
return (double) millis / 1000.00;
longgetElapsedTimeInMilliseconds(Date startDate, Date endDate)
Return the elapsed time between the start date and now.
long startMilliseconds = startDate.getTime();
long endMilliseconds = endDate.getTime();
return endMilliseconds - startMilliseconds;
longgetExpirationInMilliSeconds(long currentTime, int expirationTime)
get Expiration In Milli Seconds
long expiryInMsecs = ((long) expirationTime << 8);
long diff = expiryInMsecs - currentTime;
return (diff < 0L) ? 0L : diff;
longgetExpirationMillisAbs(int recordExpirationTimestamp)
get Expiration Millis Abs
long timestamp;
if (recordExpirationTimestamp == 0) {
    timestamp = -1; 
} else {
    timestamp = 1000L * (AS_TIMEBASE_SEC + recordExpirationTimestamp);
return timestamp;
longgetFullSecondsElapsedTimeMillis(long start, long end)
Gets full seconds elapsed time millis.
return ((long) Math.ceil((end - start) / 1000.0)) * 1000;
StringgetLogTimeFromMillis(Long millis)
get Log Time From Millis
return addLeadingZeros(String.valueOf(millis));
longgetMillis()
get Millis
return System.currentTimeMillis();
StringgetMillis()
get Millis
return MILLIS;
longgetMillis(long ticks)
Convert minecraft ticks to milliseconds.
return (long) (ticks * 50D);