Duration.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final LongRange | LONG_TO_INT_RANGE
An Integer Range that accepts Longs. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static < The function exception. T extends Throwable> void | accept(final FailableBiConsumer<Long, Integer, T>
Accepting function. consumer, final Duration The duration to pick apart. duration)Accepts the function with the duration as a long milliseconds and int nanoseconds. |
| public static Duration | Returns: a Duration of seconds.The property name. key, final TemporalUnit The unit that the duration is measured in, not null. unit, final long The default value in the given unit. def)Gets a Duration of unit stored in the system property at the given key. |
| private static long | |
| public static Duration | |
| public static int | Returns: nanoseconds between 0 and 999,999.The duration to query. duration)
Deprecated
Use
getNanosOfMilli(Duration).
Gets the nanosecond part of a Duration converted to milliseconds. |
| public static int | Returns: nanoseconds between 0 and 999,999.The duration to query. duration)Gets the nanosecond part of a Duration converted to milliseconds. |
| public static Duration | Returns: a Duration of seconds.The property name. key, final long The default value in seconds. def)Gets a Duration of seconds stored in the system property at the given key. |
| public static boolean | Returns: whether the given Duration is positive (duration > 0).the value to test duration)Tests whether the given Duration is positive (duration > 0). |
| private static <E extends Throwable> Instant | |
| public static < The type of exception throw by the lambda. E extends Throwable> Duration | Returns: The Duration of execution.What to execute. consumer)Runs the lambda and returns the duration of its execution. |
| public static < The type of exception throw by the lambda. E extends Throwable> Duration | Returns: The Duration of execution.What to execute. runnable)Runs the lambda and returns the duration of its execution. |
| public static Duration | |
| pack-priv static ChronoUnit | Returns: The corresponding ChronoUnit.A non-null TimeUnit. timeUnit)Converts a |
| public static Duration | Returns: a Duration.the amount of the duration, measured in terms of the unit, positive or negative amount, final TimeUnit the unit that the duration is measured in, must have an exact duration, not null timeUnit)Converts an amount and TimeUnit into a Duration. |
| public static int | Returns: int milliseconds.The duration to convert, not null. duration)Converts a Duration to milliseconds bound to an int (instead of a long). |
| public static Duration | Returns: The given duration orDuration#ZERO.The duration to test. duration)Returns the given non-null value or |
| LONG_TO_INT_RANGE | back to summary |
|---|---|
| pack-priv static final LongRange LONG_TO_INT_RANGE An Integer Range that accepts Longs. | |
| DurationUtils | back to summary |
|---|---|
| public DurationUtils()
Deprecated TODO Make private in 4.0. Make private in 4.0.
| |
| accept | back to summary |
|---|---|
| public static <T extends Throwable> void accept(final FailableBiConsumer<Long, Integer, T> consumer, final Duration duration) throws FailableBiConsumer:T Accepts the function with the duration as a long milliseconds and int nanoseconds.
| |
| get | back to summary |
|---|---|
| public static Duration get(final String key, final TemporalUnit unit, final long def) Gets a Duration of unit stored in the system property at the given key.
| |
| getLong | back to summary |
|---|---|
| private static long getLong(final String key, final long def) | |
| getMillis | back to summary |
|---|---|
| public static Duration getMillis(final String key, final long def) Gets a Duration of milliseconds stored in the system property at the given key. | |
| getNanosOfMiili | back to summary |
|---|---|
| public static int getNanosOfMiili(final Duration duration)
Deprecated Gets the nanosecond part of a Duration converted to milliseconds.
Handy when calling an API that takes a long of milliseconds and an int of nanoseconds. For example,
Note that is this different from
| |
| getNanosOfMilli | back to summary |
|---|---|
| public static int getNanosOfMilli(final Duration duration) Gets the nanosecond part of a Duration converted to milliseconds.
Handy when calling an API that takes a long of milliseconds and an int of nanoseconds. For example,
Note that is this different from
| |
| getSeconds | back to summary |
|---|---|
| public static Duration getSeconds(final String key, final long def) Gets a Duration of seconds stored in the system property at the given key. | |
| isPositive | back to summary |
|---|---|
| public static boolean isPositive(final Duration duration) Tests whether the given Duration is positive (duration > 0).
| |
| now | back to summary |
|---|---|
| private static <E extends Throwable> Instant now(final FailableConsumer<Instant, E> nowConsumer) throws FailableBiConsumer:E | |
| of | back to summary |
|---|---|
| public static <E extends Throwable> Duration of(final FailableConsumer<Instant, E> consumer) throws FailableBiConsumer:E Runs the lambda and returns the duration of its execution.
| |
| of | back to summary |
|---|---|
| public static <E extends Throwable> Duration of(final FailableRunnable<E> runnable) throws FailableBiConsumer:E Runs the lambda and returns the duration of its execution.
| |
| since | back to summary |
|---|---|
| public static Duration since(final Temporal startInclusive) Computes the Duration between a start instant and now. | |
| toChronoUnit | back to summary |
|---|---|
| pack-priv static ChronoUnit toChronoUnit(final TimeUnit timeUnit) Converts a
| |
| toDuration | back to summary |
|---|---|
| public static Duration toDuration(final long amount, final TimeUnit timeUnit) Converts an amount and TimeUnit into a Duration. | |
| toMillisInt | back to summary |
|---|---|
| public static int toMillisInt(final Duration duration) Converts a Duration to milliseconds bound to an int (instead of a long). Handy for low-level APIs that take millisecond timeouts in ints rather than longs.
| |
| zeroIfNull | back to summary |
|---|---|
| public static Duration zeroIfNull(final Duration duration) Returns the given non-null value or
| |