public class DateTimeUtils extends Object
| Constructor and Description |
|---|
DateTimeUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
formatUnixTimestamp(long unixTimestamp,
String timeFormat)
Convert UNIX_TIMESTAMP to string in given format.
|
static long |
instantToMicros(Instant instant)
Converts provided
Instant to microseconds (from epoch) |
static Instant |
microsToInstant(long microsFromEpoch)
Converts provided microseconds (from epoch) to
Instant |
static Instant |
parseDateTime(String s)
Parse input String to a
Instant. |
static Duration |
parseDuration(String text)
Parse the given string to a java
Duration. |
public static Instant microsToInstant(long microsFromEpoch)
Instantpublic static long instantToMicros(Instant instant)
Instant to microseconds (from epoch)public static Instant parseDateTime(String s) throws DateTimeParseException
Instant.s - Input String should be Epoch time in millisecond or ISO-8601 format.DateTimeParseExceptionpublic static Duration parseDuration(String text)
Duration. 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:
text - string to parse.Copyright © 2024 The Apache Software Foundation. All rights reserved.