Java LocalDate Compare isSameLocalDate(LocalDate first, LocalDate second)

Here you can find the source of isSameLocalDate(LocalDate first, LocalDate second)

Description

isSameLocalDate, This compares two date variables to see if their values are equal.

License

Open Source License

Declaration

static public boolean isSameLocalDate(LocalDate first, LocalDate second) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.time.*;

public class Main {
    /**/*from  ww w  . j  a  v  a 2 s.c  om*/
     * isSameLocalDate, This compares two date variables to see if their values are equal. Returns
     * true if the values are equal, otherwise returns false.
     *
     * More specifically: This returns true if both values are null (an empty date). Or, this
     * returns true if both of the supplied dates contain a date and represent the same date.
     * Otherwise this returns false.
     */
    static public boolean isSameLocalDate(LocalDate first, LocalDate second) {
        // If both values are null, return true.
        if (first == null && second == null) {
            return true;
        }
        // At least one value contains a date. If the other value is null, then return false.
        if (first == null || second == null) {
            return false;
        }
        // Both values contain dates. Return true if the dates are equal, otherwise return false.
        return first.isEqual(second);
    }
}

Related

  1. isSameMonthAndDay(@Nonnull final LocalDate x, @Nonnull final LocalDate y)
  2. isSameYearAndWeek(@Nonnull final LocalDate x, @Nonnull final LocalDate y, @Nonnull final Locale aLocale)