698 *
699 * @param other the other date to compare to, not null
700 * @return the comparator value, negative if less, positive if greater
701 */
702 @Override
703 default int compareTo(ChronoLocalDate other) {
704 int cmp = Long.compare(toEpochDay(), other.toEpochDay());
705 if (cmp == 0) {
706 cmp = getChronology().compareTo(other.getChronology());
707 }
708 return cmp;
709 }
710
711 /**
712 * Checks if this date is after the specified date ignoring the chronology.
713 * <p>
714 * This method differs from the comparison in {@link #compareTo} in that it
715 * only compares the underlying date and not the chronology.
716 * This allows dates in different calendar systems to be compared based
717 * on the time-line position.
718 * This is equivalent to using {@code date1.toEpochDay() > date2.toEpochDay()}.
719 * <p>
720 * This default implementation performs the comparison based on the epoch-day.
721 *
722 * @param other the other date to compare to, not null
723 * @return true if this is after the specified date
724 */
725 default boolean isAfter(ChronoLocalDate other) {
726 return this.toEpochDay() > other.toEpochDay();
727 }
728
729 /**
730 * Checks if this date is before the specified date ignoring the chronology.
731 * <p>
732 * This method differs from the comparison in {@link #compareTo} in that it
733 * only compares the underlying date and not the chronology.
734 * This allows dates in different calendar systems to be compared based
735 * on the time-line position.
736 * This is equivalent to using {@code date1.toEpochDay() < date2.toEpochDay()}.
737 * <p>
738 * This default implementation performs the comparison based on the epoch-day.
739 *
740 * @param other the other date to compare to, not null
741 * @return true if this is before the specified date
742 */
743 default boolean isBefore(ChronoLocalDate other) {
744 return this.toEpochDay() < other.toEpochDay();
745 }
746
747 /**
748 * Checks if this date is equal to the specified date ignoring the chronology.
749 * <p>
750 * This method differs from the comparison in {@link #compareTo} in that it
751 * only compares the underlying date and not the chronology.
752 * This allows dates in different calendar systems to be compared based
753 * on the time-line position.
754 * This is equivalent to using {@code date1.toEpochDay() == date2.toEpochDay()}.
755 * <p>
756 * This default implementation performs the comparison based on the epoch-day.
|
698 *
699 * @param other the other date to compare to, not null
700 * @return the comparator value, negative if less, positive if greater
701 */
702 @Override
703 default int compareTo(ChronoLocalDate other) {
704 int cmp = Long.compare(toEpochDay(), other.toEpochDay());
705 if (cmp == 0) {
706 cmp = getChronology().compareTo(other.getChronology());
707 }
708 return cmp;
709 }
710
711 /**
712 * Checks if this date is after the specified date ignoring the chronology.
713 * <p>
714 * This method differs from the comparison in {@link #compareTo} in that it
715 * only compares the underlying date and not the chronology.
716 * This allows dates in different calendar systems to be compared based
717 * on the time-line position.
718 * This is equivalent to using {@code date1.toEpochDay() > date2.toEpochDay()}.
719 * <p>
720 * This default implementation performs the comparison based on the epoch-day.
721 *
722 * @param other the other date to compare to, not null
723 * @return true if this is after the specified date
724 */
725 default boolean isAfter(ChronoLocalDate other) {
726 return this.toEpochDay() > other.toEpochDay();
727 }
728
729 /**
730 * Checks if this date is before the specified date ignoring the chronology.
731 * <p>
732 * This method differs from the comparison in {@link #compareTo} in that it
733 * only compares the underlying date and not the chronology.
734 * This allows dates in different calendar systems to be compared based
735 * on the time-line position.
736 * This is equivalent to using {@code date1.toEpochDay() < date2.toEpochDay()}.
737 * <p>
738 * This default implementation performs the comparison based on the epoch-day.
739 *
740 * @param other the other date to compare to, not null
741 * @return true if this is before the specified date
742 */
743 default boolean isBefore(ChronoLocalDate other) {
744 return this.toEpochDay() < other.toEpochDay();
745 }
746
747 /**
748 * Checks if this date is equal to the specified date ignoring the chronology.
749 * <p>
750 * This method differs from the comparison in {@link #compareTo} in that it
751 * only compares the underlying date and not the chronology.
752 * This allows dates in different calendar systems to be compared based
753 * on the time-line position.
754 * This is equivalent to using {@code date1.toEpochDay() == date2.toEpochDay()}.
755 * <p>
756 * This default implementation performs the comparison based on the epoch-day.
|