Java Date compareTo() Method22 Mar 2025 | 1 min read The compareTo() method of Java Date class compares two dates and sort them for order. This method is specified by compareTo in interface Comparable<Date>. Syntax:ParametersanotherDate - a date to be compared Return
ExceptionNullPointerException will be thrown if anotherDate is null. Example 1Output: Your comparison value is : -1 Example 2Output: Your comparision value is : 0 Example 3Output: Your comparison value is : 1 Next Topicjava.util.Date |
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India