List of utility methods to do LocalDate Calculate
LocalDate | getLrsLocalDate(String lbdcDate) Extract the LocalDate value from the LRS formatted date string. return LocalDate.from(LRS_DATE_ONLY_FORMAT.parse(lbdcDate));
|
LocalDate | getMax(@Nonnull final LocalDate aDate1, @Nonnull final LocalDate aDate2) get Max return aDate1.isAfter(aDate2) ? aDate1 : aDate2;
|
LocalDate | getNextNoWeekedDay(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()); ... |
long | getTimeDifferenceInDays(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); |
LocalDate | getTodayAsLocalDate() Returns today's date as a LocalDate LocalDate today = LocalDate.now();
return today;
|
int | getWeekOfTheYear(final LocalDate dateOfYear) Returns the numerical week of the year given a date per the ISO 8601 standard. return dateOfYear.get(WeekFields.ISO.weekOfWeekBasedYear());
|
YearMonth | getYearMonth(LocalDate localDate) Gets the YearMonth of a specified LocalDate . return localDate != null ? YearMonth.of(localDate.getYear(), localDate.getMonth()) : null;
|
Boolean | isActual(LocalDate before, LocalDate after) is Actual LocalDate date = LocalDate.now();
return date.isAfter(before) && date.isBefore(after);
|
boolean | isAnyLocalDate(Object obj) Is the object local date or local date-time or local time? return isLocalDateOrDateTime(obj) || obj instanceof LocalTime; |