Here you can find the source of isWithin(LocalDateTime start, LocalDateTime end)
Parameter | Description |
---|---|
start | Start time |
end | End time <p> |
Parameter | Description |
---|---|
IllegalArgumentException | if start is not before end |
public static Predicate<LocalDateTime> isWithin(LocalDateTime start, LocalDateTime end)
//package com.java2s; //License from project: Apache License import java.time.LocalDateTime; import java.util.function.Predicate; public class Main { /**// www . j a v a 2 s . c o m * Returns a {@link Predicate} that returns true if a {@link LocalDateTime} is between two others. * <p> * @param start Start time * @param end End time * <p> * @return predicate * <p> * @throws IllegalArgumentException if start is not before end */ public static Predicate<LocalDateTime> isWithin(LocalDateTime start, LocalDateTime end) { if (!start.isBefore(end)) { throw new IllegalArgumentException("Start " + start + " must be before end " + end); } return dt -> !dt.isBefore(start) && dt.isBefore(end); } }