Java LocalDate Calculate next(Predicate p)

Here you can find the source of next(Predicate p)

Description

Returns a TemporalAdjuster which returns the next date fulfilling the predicate.

License

Open Source License

Parameter

Parameter Description
p Predicate

Exception

Parameter Description
NullPointerException if p is null

Return

a TemporalAdjuster

Declaration

static public TemporalAdjuster next(Predicate<LocalDate> p) 

Method Source Code


//package com.java2s;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjuster;
import java.util.Objects;
import java.util.function.Predicate;

public class Main {
    /**//www .ja  v a  2 s  .c om
     * Returns a TemporalAdjuster which returns the next date fulfilling the predicate.
     * @param p Predicate
     * @return  a TemporalAdjuster
     * @throws NullPointerException if p is null
     */
    static public TemporalAdjuster next(Predicate<LocalDate> p) {
        Objects.requireNonNull(p, "p is null");

        return w -> {
            LocalDate result = (LocalDate) w;
            do {
                result = result.plusDays(1);
            } while (!p.test(result));
            return result;
        };
    }
}

Related

  1. localDateToSystemAdjustedStartOfDayDate(LocalDate d)
  2. max(ChronoLocalDate date1, ChronoLocalDate date2)
  3. medTime(LocalDate date, String text)
  4. minusDaysAdjustedToStartOfDay(LocalDate ld, int days)
  5. newToOld(LocalDate d)
  6. normalizedYear(LocalDate d)
  7. obtenirLocalDateAPartirDUneDate(Date date)
  8. oneDayAfterNotificationRequired(LocalDate requestDate, LocalDate vehicleDetailsMotExpiryDate)
  9. parseDate(LocalDate date)