Calendar class clone() method example
Calendar class clone() method example. This example shows you how to use clone() method.This method Creates and returns a copy of this object.
Here is the code:-
/**
* @Program that Creates and returns a copy of this object.
* clonecalender.java
* Author:-RoseIndia Team
* Date:-21-May-2008
*/
import java.util.*;
public class clonecalender {
public static void main(String[] args) {
//Creating a calender
Calendar c = new GregorianCalendar(2006,04,25);
// Creates and returns a copy of this object.
Calendar c1 = (Calendar) c.clone();
//displaying the copy of object c
System.out.println(c1.getTime());
}
} |
Output of the program:-
| Thu May 25 00:00:00 IST 2006 |
|