Java Utililty Methods Date to LocalDateTime

List of utility methods to do Date to LocalDateTime

Description

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

Method

LocalDateTimetoLocalDateTime(BigDecimal comTime)
to Local Date Time
BigDecimal daysAfterZero = comTime.setScale(0, RoundingMode.DOWN);
BigDecimal fraction = comTime.subtract(daysAfterZero).abs(); 
BigDecimal fractionMillisAfterZero = fraction.multiply(MILLIS_PER_DAY).setScale(0, RoundingMode.HALF_DOWN);
return ZERO_COM_TIME.plusDays(daysAfterZero.intValue()).plus(fractionMillisAfterZero.longValue(),
        ChronoUnit.MILLIS);
LocalDateTimetoLocalDateTime(Date date)
to Local Date Time
if (date == null) {
    return null;
Instant instant = Instant.ofEpochMilli(date.getTime());
return LocalDateTime.ofInstant(instant, getZoneId());
LocalDateTimetoLocalDateTime(Date date)
to Local Date Time
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
ZonedDateTime zdt = cal.toZonedDateTime();
return zdt.toLocalDateTime();
LocalDateTimetoLocalDateTime(Date date)
to Local Date Time
return LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), DEFAULT_ZONEID);
LocalDateTimetoLocalDateTime(Date dateTime)
Convert a Date value into a LocalDateTime , using default calendar and default time zone.
return toLocalDateTime(dateTime, null);
LocalDateTimetoLocalDateTime(Date utilDate)
to Local Date Time
if (utilDate == null) {
    return null;
ZonedDateTime zonedDateTime = toZonedDateTime(utilDate);
return zonedDateTime.toLocalDateTime();
LocalDateTimetoLocalDateTime(long timestamp)
to Local Date Time
return toZonedDateTime(timestamp).toLocalDateTime();
LocalDateTimetoLocalDateTime(String date, int time)
to Local Date Time
String toParse = String.format("%sT%02d:%02d:00", date, time / 100, time % 100);
return LocalDateTime.parse(toParse);
LocalDateTimetoLocalDateTime(String dateValue, String timeValue)
This method parse date and time from String objects to LocalDateTime object.
return LocalDateTime.of(toLocalDate(dateValue), toLocalTime(timeValue));
LocalDateTimetoLocalDateTime(String string)
to Local Date Time
if (string == null) {
    return null;
return LocalDateTime.parse(string, FORMATTER);