Java GregorianCalendar.clone()
Syntax
GregorianCalendar.clone() has the following syntax.
public Object clone()
Example
In the following code shows how to use GregorianCalendar.clone() method.
//from w ww . ja v a 2 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.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »