Java Utililty Methods LocalDateTime from

List of utility methods to do LocalDateTime from

Description

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

Method

LocalDateTimeconvertToLocalDateTime(String time)
convert To Local Date Time
time = time.substring(0, time.indexOf("."));
return LocalDateTime.parse(time, dateTimeFormatter);
InstantconvertToSystemTime(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();
ZonedDateTimedateToLocalDateTime(Date date)
date To Local Date Time
Instant endDateInstant = Instant.ofEpochMilli(date.getTime());
return ZonedDateTime.ofInstant(endDateInstant, ZoneOffset.UTC);
longdateToLong(LocalDateTime date)
Convert a UTC LocalDateTime to a long milliseconds value for storage in the database
return date.toInstant(ZoneOffset.UTC).toEpochMilli();
LocalDateTimelocalDateTimeFromDate(Date date)
local Date Time From Date
return LocalDateTime.parse(new SimpleDateFormat("YYYY-MM-dd'T'HH:mm").format(date));