List of utility methods to do LocalDate Calculate
TemporalAdjuster | next(Predicate Returns a TemporalAdjuster which returns the next date fulfilling the predicate. Objects.requireNonNull(p, "p is null"); return w -> { LocalDate result = (LocalDate) w; do { result = result.plusDays(1); } while (!p.test(result)); return result; }; ... |
String | normalizedYear(LocalDate d) normalized Year if (d == null) return null; int yr = d.getYear(); int mo = d.getMonthValue(); int day = d.getDayOfMonth(); if (mo == 12 && day == 31) { yr++; return String.valueOf(yr); |
LocalDate | obtenirLocalDateAPartirDUneDate(Date date) obtenir Local Date A Partir D Une Date return (date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
boolean | oneDayAfterNotificationRequired(LocalDate requestDate, LocalDate vehicleDetailsMotExpiryDate) one Day After Notification Required return requestDate.minusDays(1).equals(vehicleDetailsMotExpiryDate);
|
java.util.Date | parseDate(LocalDate date) parse Date if (date != null) { return java.util.Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()); } else { return null; |
Period | period(LocalDate startDate, LocalDate endDate) period return Period.between(startDate, endDate);
|
LocalDate | plusDays(LocalDate date, int daysToAdd) Adds a number of days to the date. if (daysToAdd == 0) { return date; long dom = date.getDayOfMonth() + daysToAdd; if (dom > 0 && dom <= 59) { int monthLen = date.lengthOfMonth(); int month = date.getMonthValue(); int year = date.getYear(); ... |
void | rebucketingArray(List Re-bucket one sensitivity at a specific date and add it to an existing array. int nbBuckets = targetDates.size(); if (!sensitivityDate.isAfter(targetDates.get(0))) { rebucketedSensitivityAmounts[0] += sensitivityAmount; } else if (!sensitivityDate.isBefore(targetDates.get(nbBuckets - 1))) { rebucketedSensitivityAmounts[nbBuckets - 1] += sensitivityAmount; } else { int indexSensitivityDate = 0; while (sensitivityDate.isAfter(targetDates.get(indexSensitivityDate))) { ... |
LocalDate | roundDown(final LocalDate dateTime, final TemporalUnit temporalUnit, final int size) round Down LocalDate epoch = LocalDate.ofEpochDay(0); long count = temporalUnit.between(epoch, dateTime); long round = count / size * size; long diff = round - count; return dateTime.plus(diff, temporalUnit); |
Stream | stream(LocalDate startInclusive, LocalDate endExclusive) Streams the set of dates included in the range. Iterator<LocalDate> it = new Iterator<LocalDate>() { private LocalDate current = startInclusive; @Override public LocalDate next() { LocalDate result = current; current = plusDays(current, 1); return result; @Override public boolean hasNext() { return current.isBefore(endExclusive); }; long count = endExclusive.toEpochDay() - startInclusive.toEpochDay() + 1; Spliterator<LocalDate> spliterator = Spliterators.spliterator(it, count, Spliterator.IMMUTABLE | Spliterator.NONNULL | Spliterator.DISTINCT | Spliterator.ORDERED | Spliterator.SORTED | Spliterator.SIZED | Spliterator.SUBSIZED); return StreamSupport.stream(spliterator, false); |