public final class DateTimeUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static long |
YEAR_DURATION_MILLS |
| Modifier and Type | Method and Description |
|---|---|
static LocalDateTime |
dateTimeFromEpochMills(long dateTimeAsMills)
Obtains an instance of
LocalDateTime using milliseconds from the
epoch of 1970-01-01T00:00:00Z. |
static LocalDate |
fromEpochMills(long dateAsMills) |
static LocalDateTime |
fromEpochMills(long dateTimeAsMills,
ZoneId zone)
Obtains an instance of
LocalDateTime using milliseconds from the
epoch of 1970-01-01T00:00:00Z. |
static long |
getNowUtcMills() |
static ChronoUnit |
toChronoUnit(TimeUnit unit) |
static long |
toEpochMills(LocalDate date)
calculate milliseconds past from the epoch of 1970-01-01T00:00:00Z.
|
static long |
toEpochMills(LocalDateTime dateTime)
calculatee milliseconds past from the epoch of 1970-01-01T00:00:00Z.
|
static long |
toEpochMills(OffsetDateTime dateTime) |
static String |
toLocalString(LocalDate date)
convert date to string divided by '/'
|
static String |
toLocalString(LocalDateTime dateTime)
convert date to string divided by '/'
|
static TimeUnit |
toTimeUnit(ChronoUnit unit) |
public static final long YEAR_DURATION_MILLS
public static long toEpochMills(LocalDate date)
date - an instance of (@code LocalDate)IllegalArgumentException - if null date passed to method.public static LocalDate fromEpochMills(long dateAsMills)
public static LocalDateTime dateTimeFromEpochMills(long dateTimeAsMills)
LocalDateTime using milliseconds from the
epoch of 1970-01-01T00:00:00Z.
The seconds and nanoseconds are extracted from the specified milliseconds.
dateTimeAsMills - the number of milliseconds after 1970-01-01T00:00:00ZDateTimeException - if the instant exceeds the maximum or minimum instantpublic static LocalDateTime fromEpochMills(long dateTimeAsMills, ZoneId zone)
LocalDateTime using milliseconds from the
epoch of 1970-01-01T00:00:00Z.
The seconds and nanoseconds are extracted from the specified milliseconds.
dateTimeAsMills - the number of milliseconds from 1970-01-01T00:00:00Z.zone - an isntance of (@code ZoneId) specify zone id for calculating LocalDateTimeDateTimeException - if the instant exceeds the maximum or minimum instantIllegalArgumentException - if null zone passed to method.public static long toEpochMills(LocalDateTime dateTime)
dateTime - an instance of (@code LocalDateTime)IllegalArgumentException - if null dateTime passed to method.public static long toEpochMills(OffsetDateTime dateTime)
public static String toLocalString(LocalDateTime dateTime)
dateTime - the dateTimepublic static String toLocalString(LocalDate date)
date - the dateTimepublic static TimeUnit toTimeUnit(ChronoUnit unit)
public static ChronoUnit toChronoUnit(TimeUnit unit)
public static long getNowUtcMills()
Copyright © 2020. All rights reserved.