Java Utililty Methods TimeUnit Usage

List of utility methods to do TimeUnit Usage

Description

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

Method

inttoBias(long offset)
to Bias
return (int) TimeUnit.MILLISECONDS.toMinutes(-offset);
longtodayInMillis()
today In Millis
return TimeUnit.DAYS.toMillis(TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis()));
LongtoDays(Date date)
to Days
if (date == null) {
    return null;
} else {
    return new Long(java.util.concurrent.TimeUnit.MILLISECONDS.toDays(date.getTime()));
longtodayStart()
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();
StringtoHeaderValue(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) {
...
longtoMsTime(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;
StringtoString(final Stopwatch watch)
to String
return nanoToReadableString(watch.elapsed(NANOSECONDS));
StringtoString(long milliseconds)
to String
return String.format("%02d:%02d", TimeUnit.MILLISECONDS.toMinutes(milliseconds),
        TimeUnit.MILLISECONDS.toSeconds(milliseconds)
                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds)));
longtoUnixTime(Date date)
to Unix Time
return toUnixTime(date.getTime());
longunixToJavaTime(long utime)
unix To Java Time
return TimeUnit.MILLISECONDS.convert(utime, TimeUnit.SECONDS);