ChronoLocalDate compareTo() method in Java with Examples
The compareTo() method of ChronoLocalDate interface in Java method compares this date to another date.
public int compareTo(ChronoLocalDate other)
Parameter: This method accepts a parameter other which specifies the other date to compare to and it is not specifically null.
Return Value: It returns the comparator value which is negative if it is less else it is positive if it is greater.
Below programs illustrate the compareTo() method of ChronoLocalDate in Java:
2018-11-01 2018-11-14 13
2018-11-21 2018-11-14 -7
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.