public class Dates extends Object
| Modifier and Type | Field and Description |
|---|---|
static DateTimeFormatter |
DATE_TOSTRING |
static DateTimeFormatter |
RFC_7231_DATE_TIME |
static TimeZone |
UTC_TIME_ZONE |
static ZoneId |
UTC_ZONE_ID |
| Modifier and Type | Method and Description |
|---|---|
static String |
formatMillis(DateTimeFormatter formatter,
long epochMilli)
Format epoch milliseconds to a string.
|
static ZonedDateTime |
parse(String dateString)
Return a ZonedDateTime that is set to the given datestring.
|
static long |
parseMillis(DateTimeFormatter formatter,
String time)
Parse a string into epoch milliseconds.
|
static ZonedDateTime |
toZonedDateTime(LocalDate date,
LocalTime time,
ZoneId zone)
Return a new ZonedDateTime based on a local date, time, and zone.
|
static ZonedDateTime |
toZonedDateTime(long epochMilli)
Return a new ZonedDateTime based on a epoch milliseconds.
|
static ZonedDateTime |
toZonedDateTime(TemporalAccessor temporal)
Turn a TemporalAccessor into a ZonedDateTime using defaults for missing
fields.
|
public static final ZoneId UTC_ZONE_ID
public static final TimeZone UTC_TIME_ZONE
public static final DateTimeFormatter RFC_7231_DATE_TIME
public static final DateTimeFormatter DATE_TOSTRING
public static ZonedDateTime parse(String dateString)
dateString - a date formatted stringpublic static ZonedDateTime toZonedDateTime(TemporalAccessor temporal)
toZonedDateTime(TemporalAccessor) for defaults.temporal - the temporal to turn into ZonedDateTimeZonedDateTimepublic static ZonedDateTime toZonedDateTime(LocalDate date, LocalTime time, ZoneId zone)
date - the localdate, when null, the current date is usedtime - the time, when null, 00:00:00.000 is usedzone - the time zone, when null, UTC is usedZonedDateTimepublic static ZonedDateTime toZonedDateTime(long epochMilli)
epochMilli - the number of milliseconds from 1970-01-01T00:00:00ZZonedDateTime using UTC time zone.public static long parseMillis(DateTimeFormatter formatter, String time)
formatter - The formatter to parse the string with.time - Time string to parse into epoch milliseconds.public static String formatMillis(DateTimeFormatter formatter, long epochMilli)
formatter - The formatter to format the epoch milliseconds with.epochMilli - Number of milliseconds from 1970-01-01T00:00:00Z.Copyright © 2021. All rights reserved.