public class DurationUtils extends Object
| Constructor and Description |
|---|
DurationUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
formatDuration(Duration duration)
Formats the given duration in plain English text.
|
static Duration |
round(Duration duration,
TimeUnit unit)
Rounds the given duration to the given time unit.
|
@NonNull public static Duration round(@NonNull Duration duration, @NonNull TimeUnit unit)
Conversions from finer to coarser granularities may result in precision loss; in such cases, rounding is done towards the floor. For example, rounding 119 seconds to minutes will result in one minute.
duration - The duration to round.unit - The unit to round to.@NonNull public static String formatDuration(@NonNull Duration duration)
duration - The duration to format, must be non-null and strictly positive.IllegalArgumentException - if the duration is negative or zero.Copyright © 2017–2021 DataStax. All rights reserved.