Java Utililty Methods LocalDate Calculate

List of utility methods to do LocalDate Calculate

Description

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

Method

booleanisWeekend(LocalDate date)
is Weekend
return date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY;
booleanisWorkDay(@Nonnull final LocalDate aDate)
is Work Day
return !isWeekend(aDate);
intlastMonth(LocalDate date)
last Month
return date.minusMonths(1).getMonthValue();
longlocalDate2ms(final LocalDate ld)
LocalDate to ms.
return ld.atStartOfDay().toEpochSecond(ZoneOffset.ofHours(9)) * 1000L;
LocalDateLocalDateFromMilli(long value)
Local Date From Milli
final Instant instant = Instant.ofEpochMilli(value);
final LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
return localDateTime.toLocalDate();
DatelocalDateToSystemAdjustedStartOfDayDate(LocalDate d)
Adjusts a LocalDate to Midnight of the say day (start of day).
LocalDateTime ldt = d.atStartOfDay();
return getSystemDefaultDate(ldt);
LocalDatemax(ChronoLocalDate date1, ChronoLocalDate date2)
max
return LocalDate.from(date1.isBefore(date2) ? date2 : date1);
InstantmedTime(LocalDate date, String text)
med Time
return LocalDateTime.of(date, LocalTime.parse(text)).atZone(ZoneId.systemDefault()).toInstant();
LocalDateTimeminusDaysAdjustedToStartOfDay(LocalDate ld, int days)
Takes the LocalDate, subtracts the day indicated from it, and adjusts it to Midnight (start of day).
return ld.minusDays(days).atStartOfDay();
DatenewToOld(LocalDate d)
new To Old
return newToOld(d.atStartOfDay());