List of utility methods to do LocalDateTime from
LocalDateTime | convertToLocalDateTime(String time) convert To Local Date Time time = time.substring(0, time.indexOf(".")); return LocalDateTime.parse(time, dateTimeFormatter); |
Instant | convertToSystemTime(LocalDateTime userInput, ZoneId userZoneId) convert To System Time Objects.requireNonNull(userInput, "Local date time is required"); Objects.requireNonNull(userZoneId); ZonedDateTime userTime = ZonedDateTime.of(userInput, userZoneId); ZonedDateTime systemTime = userTime.withZoneSameInstant(zoneSystem); return systemTime.toInstant(); |
ZonedDateTime | dateToLocalDateTime(Date date) date To Local Date Time Instant endDateInstant = Instant.ofEpochMilli(date.getTime());
return ZonedDateTime.ofInstant(endDateInstant, ZoneOffset.UTC);
|
long | dateToLong(LocalDateTime date) Convert a UTC LocalDateTime to a long milliseconds value for storage in the database return date.toInstant(ZoneOffset.UTC).toEpochMilli();
|
LocalDateTime | localDateTimeFromDate(Date date) local Date Time From Date return LocalDateTime.parse(new SimpleDateFormat("YYYY-MM-dd'T'HH:mm").format(date)); |