Java Calendar clone方法


Java Calendar clone方法

package com.codingdict;

import java.util.*;

public class CalendarDemo {
   public static void main(String[] args) {

      // create new calendar at specific date.
      Calendar cal = new GregorianCalendar(2008, 05, 20);

      // print date for default value
      System.out.println("Past calendar : " + cal.getTime());

      // create a clone of first cal
      Calendar cal2 = (Calendar) cal.clone();

      // display the copy
      System.out.println("Cloned calendar : " + cal2.getTime());
   }
}