List of utility methods to do TimeUnit Convert
Double | toMillis(Double sourceValue, TimeUnit sourceUnit) to Millis if (sourceUnit == null || sourceValue == null) { return null; switch (sourceUnit) { case DAYS: return sourceValue * 86400000; case MICROSECONDS: return sourceValue * 0.001; ... |
long | toMillis(final long interval, final TimeUnit tu) Convert time interval to milliseconds. if (interval < 0L) { throw new IllegalArgumentException("SleepUtilities.toMillis " + "Negative interval"); long millis = 0L; switch (tu) { case SECONDS: millis = tu.toMillis(interval); break; ... |
long | toMillis(int duration, TimeUnit unit) Convert time duration to milliseconds. switch (unit) { case DAYS: return duration * 86400 * 1000; case HOURS: return duration * 3600 * 1000; case MINUTES: return duration * 60 * 1000; case SECONDS: ... |
long | toMillis(long duration, TimeUnit timeUnit) to Millis return TimeUnit.MILLISECONDS.convert(duration, timeUnit);
|
long | toMillis(long duration, TimeUnit unit) -1 means infinite. if (duration == 0 || unit == null) { return 0; } else if (duration < 0) { return -1; } else { return unit.toMillis(duration); |
long | toMillis(long time, TimeUnit unit) Convert the specified duration expressed in the specfied time unit into milliseconds. long millis = TimeUnit.MILLISECONDS.equals(unit) ? time : unit.convert(time, TimeUnit.MILLISECONDS); long remainder = 0L; if (TimeUnit.NANOSECONDS.equals(unit)) { remainder = time % 1000000L; if (remainder >= 500000L) millis++; } else if (TimeUnit.MICROSECONDS.equals(unit)) { remainder = time % 1000L; ... |
long | toMillis(String timeUnitString, String timeValue) Converts timeValue in timeUnitString to milliseconds TimeUnit timeUnit = timeUnitFromString(timeUnitString);
return (timeUnit == null) ? Long.MIN_VALUE : timeUnit.toMillis(Long.parseLong(timeValue));
|
long | toNanos(long timeout, TimeUnit unit) to Nanos return timeout < 0 ? -1 : (timeout == 0 ? 0 : (((timeout = unit.toNanos(timeout)) < 0) ? 0 : timeout));
|
int | toSeconds(long duration, TimeUnit timeUnit) to Seconds int seconds = (int) timeUnit.toSeconds(duration); long inverseDuration = timeUnit.convert(seconds, TimeUnit.SECONDS); if (duration > inverseDuration) { seconds++; return seconds; |
long | toSeconds(long timeout, TimeUnit unit) Converts the given timeout to seconds. return roundUpIfNecessary(timeout, unit.toSeconds(timeout));
|