List of utility methods to do LocalDate Calculate
LocalDate | stringDateToLocalDate(String day, String month, String year) string Date To Local Date final StringBuilder sb = new StringBuilder().append(month).append("-").append(day).append("-").append(year); return LocalDate.parse(sb.toString(), simpleDateFormatter); |
LocalDate | stringToLocalDate(String birthDate) string To Local Date if (birthDate.length() != 8) { throw new IllegalArgumentException("Birth date must be of form yyyyMMdd, i.e. eight characters long."); return LocalDate.of(Integer.parseInt(birthDate.substring(0, 4)), Integer.parseInt(birthDate.substring(4, 6)), Integer.parseInt(birthDate.substring(6, 8))); |
boolean | subscriptionDeletionRequired(LocalDate vehicleMotExpiryDate, LocalDate requestDate) subscription Deletion Required LocalDate deletionDate = vehicleMotExpiryDate.plusMonths(MONTHS_BEFORE_DELETION);
return (requestDate.isAfter(deletionDate) || requestDate.isEqual(deletionDate));
|
long | toMilliseconds(LocalDate localDate) Converts local date time to epoh milliseconds assuming start of the day as time point. return toMilliseconds(localDate.atStartOfDay());
|
int | toPgDays(LocalDate date) to Pg Days LocalDateTime dateTime = date.atStartOfDay(); long secs = toPgSecs(getSecondsSinceJavaEpoch(dateTime)); return (int) TimeUnit.SECONDS.toDays(secs); |
boolean | withinAYearFromNow(LocalDate date) within A Year From Now LocalDate withinAYear = LocalDate.of(LocalDate.now().getYear() + 1, LocalDate.now().getMonth(),
LocalDate.now().getDayOfMonth());
return (date.isBefore(withinAYear) && date.isAfter(LocalDate.now())) || date.isEqual(LocalDate.now());
|
Instant | withTime(LocalDate day, int hours, int minutes) with Time if (day == null) { day = LocalDate.now(); LocalDateTime dateTime = LocalDateTime.of(day, LocalTime.of(hours, minutes)); return toInstant(dateTime); |
LocalDate | yyyyMMddToLocalDate(String dateStr) yyyy M Mdd To Local Date if (dateStr == null) { return null; return LocalDate.parse(dateStr, DateTimeFormatter.ofPattern(YYYYMMDD)); |