java.util.Calendar.equals() is a method in Calendar class of java.util package. The method compares this Calendar to the specified Object.The method returns true if this object is equal to object. If this is not the case, i.e, if there is any difference in the parameters between the two Calendars, then false is returned.
public boolean equals(Object object) Where, object is the Object to be compared with.
Below are some examples to understand the implementation of the Calendar.equals() function in a better way.
Example 1 :
Time 1 : Thu Mar 01 09:36:17 UTC 2018 Time 2 : Thu Mar 01 09:36:17 UTC 2018 true
Example 2 :
Current date is : Thu Mar 01 09:39:30 UTC 2018 Year is 2010 Result : false
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.