DEV Community

taijidude
taijidude

Posted on

Check if date is between two other dates

A small method to check if a LocalDataTime is in a Range between to other LocalDateTime - Objects.

private boolean isInDateRange(
                        LocalDateTime upper,
                        LocalDateTime lower,
                        LocalDateTime toCheck) {
    var isUpper = toCheck.equals(upper);
    var isLower = toCheck.equals(lower);
    if (isLower || isUpper) {
        return true;
    }
    return toCheck.isBefore(upper) && toCheck.isAfter(lower);
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more