Java tutorial
import java.util.*; public class Main { public static void main(String[] args) { GregorianCalendar cal1 = (GregorianCalendar) GregorianCalendar.getInstance(); // create a second calendar equal to first one GregorianCalendar cal2 = (GregorianCalendar) (Calendar) cal1.clone(); // print cal2 System.out.println(cal2.getTime()); // compare the two calendars System.out.println("Cal1 and Cal2 are equal:" + cal1.equals(cal2)); // change cal 2 a bit cal2.add(GregorianCalendar.YEAR, 5); // compare the two calendars System.out.println("Cal1 and Cal2 are equal:" + cal1.equals(cal2)); } }