List of utility methods to do LocalDate Calculate
LocalDate | adjustDate(final LocalDate contextDate, String str, final boolean add) adjust Date int hours = 0; int minutes = 0; int days = 0; int months = 0; int years = 0; if (str.endsWith("H")) { str = str.substring(0, str.length() - 1); hours = Integer.valueOf(str).intValue(); ... |
Date | asDate(LocalDate date) as Date Instant instant = date.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
return Date.from(instant);
|
long | asEpochMilli(final LocalDate localDate) Converts a LocaleDate into milliseconds from the epoch of 1970-01-01T00:00:00Z. return localDate.atStartOfDay(ZoneId.systemDefault()).toEpochSecond() * MILLISECONDS_PER_SECOND;
|
LocalDateTime | atEndOfDay(LocalDate date) Returns a LocalDateTime that represents the time just before the start of the next day. return date.atTime(23, 59, 59, 999999999);
|
boolean | before(final LocalDate d1, final LocalDate d2) Determines if LocalDate d1 occurs before LocalDate d2. return before(d1, d2, true);
|
LocalDate | calcNextDayOfWeek(LocalDate d, DayOfWeek dow) Find the next day of the week from the given LocalDate return d.with(TemporalAdjusters.next(dow));
|
int | calculateAge(LocalDate birthDate, LocalDate currentDate) calculate Age if ((birthDate != null) && (currentDate != null)) { return Period.between(birthDate, currentDate).getYears(); } else { return 0; |
LocalDate | changeDateToLocalDate(Date value) change Date To Local Date if (value == null || value.toInstant() == null) return null; Instant instant = value.toInstant(); ZonedDateTime zdt = instant.atZone(ZoneId.systemDefault()); LocalDate date = zdt.toLocalDate(); return date; |
Date | convert(LocalDate ld) convert Instant instant = ld.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
return Date.from(instant);
|
String | convertDatabaseDateToUS(LocalDate databaseDate) convert Database Date To US if (databaseDate != null) { return databaseDate.format(DateTimeFormatter.ofPattern("MM/dd/YYYY")); } else { return ""; |