Java LocalDate Calculate isValid(LocalDate ld1, LocalDate ld2, ZoneId zid, Predicate test)

Here you can find the source of isValid(LocalDate ld1, LocalDate ld2, ZoneId zid, Predicate test)

Description

is Valid

License

Apache License

Declaration

public static boolean isValid(LocalDate ld1, LocalDate ld2, ZoneId zid, Predicate<Date> test) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.time.*;

import java.util.Date;
import java.util.function.Predicate;

public class Main {
    public static boolean isValid(LocalDate ld1, LocalDate ld2, ZoneId zid, Predicate<Date> test) {
        while (ld1.compareTo(ld2) != 0) {
            if (test.test(toDate(ld1.atStartOfDay(zid))))
                return true;
            else//  ww w  .j a  v a 2 s  .co  m
                ld1 = ld1.plusDays(1);
        }
        return false;
    }

    /**
     * 
     */
    public static Date toDate(Instant v) {
        return Date.from(v);
    }

    public static Date toDate(ZonedDateTime v) {
        return Date.from(v.toInstant());
    }

    public static Date toDate(int y, int m, int d, int hh, int mm, int ss, int nano, ZoneId z) {
        return toDate(ZonedDateTime.of(y, m, d, hh, mm, ss, nano, z));
    }
}

Related

  1. isLess(@Nonnull final LocalDate aDate1, @Nonnull final LocalDate aDate2)
  2. isLocalDateAD(LocalDate date)
  3. isLocalDateOrDateTimeType(Class type)
  4. isNotNullAndAfter(LocalDate localDate1, LocalDate localDate2)
  5. isOverlapping(LocalDate firstStartDate, LocalDate firstEndDate, LocalDate secondStartDate, LocalDate secondEndDate)
  6. isWeekend(LocalDate date)
  7. isWorkDay(@Nonnull final LocalDate aDate)
  8. lastMonth(LocalDate date)
  9. localDate2ms(final LocalDate ld)