Java.util.GregorianCalendar.clone() 方法


Java.util.GregorianCalendar.clone() 方法

package com.codingdict;

import java.util.*;

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

      // create a new calendar
      GregorianCalendar cal1 = (GregorianCalendar) GregorianCalendar.getInstance();

      // print the current date and time
      System.out.println("" + cal1.getTime());

      // create a second calendar
      GregorianCalendar cal2 = new GregorianCalendar();

      // clone cal1 to cal2
      cal2 = (GregorianCalendar) cal1.clone();

      // print cal2
      System.out.println("" + cal2.getTime());
   }
}