Home > Java > javaTutorial > body text

Check if date is between two other dates

DDD
Release: 2024-09-19 06:20:27
Original
966 people have browsed it

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);
}
Copy after login

The above is the detailed content of Check if date is between two other dates. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!