Package org.apache.flink.util
Class TimeUtils
- java.lang.Object
-
- org.apache.flink.util.TimeUtils
-
public class TimeUtils extends Object
Collection of utilities about time intervals.
-
-
Constructor Summary
Constructors Constructor Description TimeUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
formatWithHighestUnit(Duration duration)
Pretty prints the duration as a lowest granularity unit that does not lose precision.static String
getStringInMillis(Duration duration)
static Duration
parseDuration(String text)
Parse the given string to a javaDuration
.
-
-
-
Method Detail
-
parseDuration
public static Duration parseDuration(String text)
Parse the given string to a javaDuration
. The string is in format "{length value}{time unit label}", e.g. "123ms", "321 s". If no time unit label is specified, it will be considered as milliseconds.Supported time unit labels are:
- DAYS: "d", "day"
- HOURS: "h", "hour"
- MINUTES: "m", "min", "minute"
- SECONDS: "s", "sec", "second"
- MILLISECONDS: "ms", "milli", "millisecond"
- MICROSECONDS: "µs", "micro", "microsecond"
- NANOSECONDS: "ns", "nano", "nanosecond"
- Parameters:
text
- string to parse.
-
getStringInMillis
public static String getStringInMillis(Duration duration)
- Parameters:
duration
- to convert to string- Returns:
- duration string in millis
-
formatWithHighestUnit
public static String formatWithHighestUnit(Duration duration)
Pretty prints the duration as a lowest granularity unit that does not lose precision.Examples:
NOTE: It supports only durations that fit into long.Duration.ofMilliseconds(60000) will be printed as 1 min Duration.ofHours(1).plusSeconds(1) will be printed as 3601 s
-
-