Java Utililty Methods LocalDateTime Calculate

List of utility methods to do LocalDateTime Calculate

Description

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

Method

LocalDateTimems2LocalDateTime(final long ms)
ms -> LocalDateTime object.
return LocalDateTime.ofInstant(Instant.ofEpochMilli(ms), ZoneId.systemDefault());
StringoldDateToISO8601LocalDateTime(Date nextColumnDate)
old Date To ISO Local Date Time
LocalDateTime localDateTime = nextColumnDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
String formattedDate = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(localDateTime);
return formattedDate;
LocalDateTimeparseStringToLocalDateTimeWithSpecifiedTime(String strDate, String time)
Parses a String into a LocalDateTime with a specified time
return parseStringToLocalDateTime(strDate + " " + time);
LocalDateTimeparseTimeStamp(LocalDateTime actualDate, LocalDateTime checkedDate, boolean isDateFrom)
parse Time Stamp
if (checkedDate != null && actualDate != null && checkIfDateExist(checkedDate)
        && !checkIfDateExist(actualDate)) {
    if (!isDateFrom) {
        actualDate = checkedDate.toLocalDate().atTime(actualDate.getHour(), actualDate.getMinute());
if (checkedDate != null && actualDate != null && checkIfTimeExist(checkedDate)
        && !checkIfTimeExist(actualDate)) {
...
StringprintDateTime(LocalDateTime dateTime)
print Date Time
return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTimerelativeDateTime(final LocalDateTime contextDate, final String str, final boolean add)
relative Date Time
LocalDateTime relativeDate = contextDate;
if (str.equals("")) {
    return contextDate;
try {
    final StringTokenizer st = new StringTokenizer(str.substring(1), " ");
    while (st.hasMoreTokens()) {
        final String token = st.nextToken();
...
LocalDateTimesafeCreateFromValue(LocalDateTime datetime, int year, int month, int day, int hour, int minute, int second)
safe Create From Value
if (isValidDate(year, month, day) && isValidTime(hour, minute, second)) {
    datetime = safeCreateFromValue(datetime, year, month, day);
    datetime = datetime.plusHours(hour - datetime.getHour());
    datetime = datetime.plusMinutes((minute - datetime.getMinute()));
    datetime = datetime.plusSeconds(second - datetime.getSecond());
return datetime;
longsecondsBetween(LocalDateTime date1, LocalDateTime date2)
Calculate the time between two dates, in seconds
return ChronoUnit.SECONDS.between(date1, date2);
LocalDateTimesetTime(LocalDateTime source, String time)
set Time
LocalTime tmp = LocalTime.parse(time, timeFormatter);
return source.withHour(tmp.getHour()) 
        .withMinute(tmp.getMinute());
LocalDateTimeshiftDateTime(String timex, LocalDateTime reference, boolean future)
shift Date Time
ImmutableMap<String, Double> timexUnitMap = resolveDurationTimex(timex);
return getShiftResult(timexUnitMap, reference, future);