List of utility methods to do TimeUnit Usage
int | toBias(long offset) to Bias return (int) TimeUnit.MILLISECONDS.toMinutes(-offset); |
long | todayInMillis() today In Millis return TimeUnit.DAYS.toMillis(TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis()));
|
Long | toDays(Date date) to Days if (date == null) { return null; } else { return new Long(java.util.concurrent.TimeUnit.MILLISECONDS.toDays(date.getTime())); |
long | todayStart() today Start final Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTimeInMillis(); |
String | toHeaderValue(long timeoutNanos) Serialize the given timeout to a String . long cutoff = 100000000; if (timeoutNanos < 0) { throw new IllegalArgumentException("Timeout too small"); } else if (timeoutNanos < cutoff) { return TimeUnit.NANOSECONDS.toNanos(timeoutNanos) + "n"; } else if (timeoutNanos < cutoff * 1000L) { return TimeUnit.NANOSECONDS.toMicros(timeoutNanos) + "u"; } else if (timeoutNanos < cutoff * 1000L * 1000L) { ... |
long | toMsTime(final String value) Converts the passed string to a ms timestamp. final long v = (long) Double.parseDouble(value.trim()); return digits(v) < 13 ? TimeUnit.SECONDS.toMillis(v) : v; |
String | toString(final Stopwatch watch) to String return nanoToReadableString(watch.elapsed(NANOSECONDS));
|
String | toString(long milliseconds) to String return String.format("%02d:%02d", TimeUnit.MILLISECONDS.toMinutes(milliseconds), TimeUnit.MILLISECONDS.toSeconds(milliseconds) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds))); |
long | toUnixTime(Date date) to Unix Time return toUnixTime(date.getTime());
|
long | unixToJavaTime(long utime) unix To Java Time return TimeUnit.MILLISECONDS.convert(utime, TimeUnit.SECONDS);
|