List of utility methods to do Date to LocalDateTime
LocalDateTime | toLocalDateTime(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);
|
LocalDateTime | toLocalDateTime(Date date) to Local Date Time if (date == null) { return null; Instant instant = Instant.ofEpochMilli(date.getTime()); return LocalDateTime.ofInstant(instant, getZoneId()); |
LocalDateTime | toLocalDateTime(Date date) to Local Date Time GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date); ZonedDateTime zdt = cal.toZonedDateTime(); return zdt.toLocalDateTime(); |
LocalDateTime | toLocalDateTime(Date date) to Local Date Time return LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), DEFAULT_ZONEID);
|
LocalDateTime | toLocalDateTime(Date dateTime) Convert a Date value into a LocalDateTime , using default calendar and default time zone. return toLocalDateTime(dateTime, null);
|
LocalDateTime | toLocalDateTime(Date utilDate) to Local Date Time if (utilDate == null) { return null; ZonedDateTime zonedDateTime = toZonedDateTime(utilDate); return zonedDateTime.toLocalDateTime(); |
LocalDateTime | toLocalDateTime(long timestamp) to Local Date Time return toZonedDateTime(timestamp).toLocalDateTime();
|
LocalDateTime | toLocalDateTime(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); |
LocalDateTime | toLocalDateTime(String dateValue, String timeValue) This method parse date and time from String objects to LocalDateTime object. return LocalDateTime.of(toLocalDate(dateValue), toLocalTime(timeValue));
|
LocalDateTime | toLocalDateTime(String string) to Local Date Time if (string == null) { return null; return LocalDateTime.parse(string, FORMATTER); |