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

LocalDategetLrsLocalDate(String lbdcDate)
Extract the LocalDate value from the LRS formatted date string.
return LocalDate.from(LRS_DATE_ONLY_FORMAT.parse(lbdcDate));
LocalDategetMax(@Nonnull final LocalDate aDate1, @Nonnull final LocalDate aDate2)
get Max
return aDate1.isAfter(aDate2) ? aDate1 : aDate2;
LocalDategetNextNoWeekedDay(LocalDate today)
get Next No Weeked Day
while (today.getDayOfWeek() == DayOfWeek.SATURDAY || today.getDayOfWeek() == DayOfWeek.SUNDAY) {
    today = today.plusDays(1);
return today;
LocalDate[]getQuarterBounds(final LocalDate date)
Returns an array of quarter bound dates of the year based on a specified date.
Objects.requireNonNull(date);
final LocalDate[] bounds = new LocalDate[8];
bounds[0] = date.with(TemporalAdjusters.firstDayOfYear());
bounds[1] = date.withMonth(Month.MARCH.getValue()).with(TemporalAdjusters.lastDayOfMonth());
bounds[2] = date.withMonth(Month.APRIL.getValue()).with(TemporalAdjusters.firstDayOfMonth());
bounds[3] = date.withMonth(Month.JUNE.getValue()).with(TemporalAdjusters.lastDayOfMonth());
bounds[4] = date.withMonth(Month.JULY.getValue()).with(TemporalAdjusters.firstDayOfMonth());
bounds[5] = date.withMonth(Month.SEPTEMBER.getValue()).with(TemporalAdjusters.lastDayOfMonth());
...
longgetTimeDifferenceInDays(LocalDate to)
get Time Difference In Days
Date today = new Date();
Date past = Date.from(Instant.from(to.atStartOfDay(ZoneId.systemDefault())));
long c = (today.getTime() - past.getTime()) - 60 * 60 * 1000;
return TimeUnit.DAYS.convert(c, TimeUnit.MILLISECONDS);
LocalDategetTodayAsLocalDate()
Returns today's date as a LocalDate
LocalDate today = LocalDate.now();
return today;
intgetWeekOfTheYear(final LocalDate dateOfYear)
Returns the numerical week of the year given a date per the ISO 8601 standard.
return dateOfYear.get(WeekFields.ISO.weekOfWeekBasedYear());
YearMonthgetYearMonth(LocalDate localDate)
Gets the YearMonth of a specified LocalDate .
return localDate != null ? YearMonth.of(localDate.getYear(), localDate.getMonth()) : null;
BooleanisActual(LocalDate before, LocalDate after)
is Actual
LocalDate date = LocalDate.now();
return date.isAfter(before) && date.isBefore(after);
booleanisAnyLocalDate(Object obj)
Is the object local date or local date-time or local time?
return isLocalDateOrDateTime(obj) || obj instanceof LocalTime;