GregorianCalendar.clone() has the following syntax.
public Object clone()
In the following code shows how to use GregorianCalendar.clone() method.
//from w w w . j a v a2 s . c o m import java.util.*; public class Main { public static void main(String[] args) { GregorianCalendar cal1 = (GregorianCalendar) GregorianCalendar.getInstance(); // create a second calendar GregorianCalendar cal2 = new GregorianCalendar(); // clone cal1 to cal2 cal2 = (GregorianCalendar) cal1.clone(); // print cal2 System.out.println(cal2.getTime()); } }
The code above generates the following result.