Java Calendar.equals(Object obj)

Syntax

Calendar.equals(Object obj) has the following syntax.

public boolean equals(Object obj)

Example

In the following code shows how to use Calendar.equals(Object obj) method.


/*from   w  ww.  ja  v a  2  s . c  o  m*/
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {

   public static void main(String[] args) {

      Calendar cal = Calendar.getInstance();

      // specify a date for one of them
      Calendar cal2 = new GregorianCalendar(2013, 06, 29);

      // compare the two calendars.
      boolean b = cal.equals(cal2);

      // print result
      System.out.println("Calendars are equal :" + b);
   }
}

The code above generates the following result.