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

LocalDateadjustDate(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();
...
DateasDate(LocalDate date)
as Date
Instant instant = date.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
return Date.from(instant);
longasEpochMilli(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;
LocalDateTimeatEndOfDay(LocalDate date)
Returns a LocalDateTime that represents the time just before the start of the next day.
return date.atTime(23, 59, 59, 999999999);
booleanbefore(final LocalDate d1, final LocalDate d2)
Determines if LocalDate d1 occurs before LocalDate d2.
return before(d1, d2, true);
LocalDatecalcNextDayOfWeek(LocalDate d, DayOfWeek dow)
Find the next day of the week from the given LocalDate
return d.with(TemporalAdjusters.next(dow));
intcalculateAge(LocalDate birthDate, LocalDate currentDate)
calculate Age
if ((birthDate != null) && (currentDate != null)) {
    return Period.between(birthDate, currentDate).getYears();
} else {
    return 0;
LocalDatechangeDateToLocalDate(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;
Dateconvert(LocalDate ld)
convert
Instant instant = ld.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
return Date.from(instant);
StringconvertDatabaseDateToUS(LocalDate databaseDate)
convert Database Date To US
if (databaseDate != null) {
    return databaseDate.format(DateTimeFormatter.ofPattern("MM/dd/YYYY"));
} else {
    return "";