List of utility methods to do LocalDate Calculate
LocalDate | getDate(Console console, Function get Date if (validator == null) validator = value -> true; String dateStr; LocalDate localDate; do { dateStr = getString(console, value -> datePattern.matcher(value).matches()); try { localDate = LocalDate.parse(dateStr, dateFormatter); ... |
Date | getDate(final LocalDate localDate) get Date Instant instant = localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
return Date.from(instant);
|
Date | getDate(LocalDate d, String tzId) get Date return getDate(d.atStartOfDay(), tzId);
|
String | getDateCriteria(LocalDate startDate, LocalDate endDate) get Date Criteria return "startDate = " + startDate.format(formatter) + " and endDate = " + endDate.format(formatter); |
Date | getDateStart(LocalDate localDate) get Date Start LocalDateTime localDateTime = localDate.atStartOfDay(); ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("Asia/Shanghai")); return Date.from(zonedDateTime.toInstant()); |
LocalDate | getEndDateOfMonth(LocalDate date) get End Date Of Month int[] ends = { 31, 30, 29, 28 }; for (int e : ends) { try { LocalDate eom = date.withDayOfMonth(e); return eom; } catch (Exception ex) { return null; |
LocalDate | getFirstDayOfTheMonth(final LocalDate date) Returns a leveled date representing the first day of the month based on a specified date. return date.with(TemporalAdjusters.firstDayOfMonth());
|
int | getLastDayInMonth(LocalDate localDate) get Last Day In Month LocalDate result = localDate.with(TemporalAdjusters.lastDayOfMonth());
return result.getDayOfMonth();
|
LocalDate | getLastDayOfTheQuarter(final LocalDate date) Returns a LocalDate date representing the last day of the quarter based on a specified date. Objects.requireNonNull(date); LocalDate result; LocalDate[] bounds = getQuarterBounds(date); if (date.compareTo(bounds[2]) < 0) { result = bounds[1]; } else if (date.compareTo(bounds[4]) < 0) { result = bounds[3]; } else if (date.compareTo(bounds[6]) < 0) { ... |
LocalDate | getLocalDateBydayAndWeek(LocalDate localDate, int weekNumber, int dayNumber) get Local Date Byday And Week return localDate.with(TemporalAdjusters.dayOfWeekInMonth(weekNumber, DayOfWeek.of(dayNumber)));
|