Java Utililty Methods LocalDateTime Create

List of utility methods to do LocalDateTime Create

Description

The list of methods to do LocalDateTime Create are organized into topic(s).

Method

LocalDateTimeasLocalDateTime(Date date)
Obtains an instance of LocalDateTime from a date object.
return asLocalDateTime(date, getDefaultTimeZone());
LocalDateTimeasLocalDateTime(Date date)
Calls #asLocalDateTime(Date,ZoneId) with the system default time zone.
return asLocalDateTime(date, ZoneId.systemDefault());
LocalDateTimegetLocalDateTime(Date datetime, TimeZone timeZone)
Find a java.time.LocalDateTime for the given user java.util.Date and java.util.TimeZone .
if (datetime == null) {
    return null;
if (timeZone == null) {
    return null;
ZoneId zoneId = timeZone.toZoneId();
return LocalDateTime.ofInstant(datetime.toInstant(), zoneId);
...
LocalDateTimegetLocalDateTimeFromEpochMilli(long epochMillis)
Convert milliseconds from epoch to a LocalDateTime with UTC offset.
final LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMillis),
        ZoneOffset.UTC.normalized());
return localDateTime;
LocalDateTimegetLocalDateTimeFromMillis(final long millis)
get Local Date Time From Millis
return LocalDateTime.of(1970, 1, 1, 0, 0, 0).plus(millis, ChronoUnit.MILLIS);
LocalDateTimegetLocalDateTimeFromMillis(long millis)
Shorthand method to return a LocalDateTime from 'millis since longAgo'.
return LocalDateTime.from(Instant.ofEpochMilli(millis));
LocalDateTimelocalDateTime(Date date, Clock clock)
local Date Time
return LocalDateTime.ofInstant(date.toInstant(), clock.getZone());
LocalDateTimelocalDateTimeOf(final String value)
Parse the given value as a local datetime.
try {
    return LocalDateTime.parse(value, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
} catch (final Exception e) {
    return null;
LocalDateTimetoLocalDateTime(java.util.Date d)
to Local Date Time
LocalDateTime ldt = (d == null ? null : LocalDateTime.fromDateFields(d));
return ldt;
ObjecttoLocalDateTime(long systemMillis)
Return the system millis time as a LocalDateTime.
return new Timestamp(systemMillis).toLocalDateTime();