Java.util.GregorianCalendar.computeFields() 方法


Java.util.GregorianCalendar.computeFields() 方法

package com.codingdict;

import java.util.*;

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

      // create a new calendar
      GregorianCalendarDemo cal = new GregorianCalendarDemo();

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

      // set a new year
      cal.set(GregorianCalendar.YEAR, 1992);
      System.out.println("" + cal.getTime());

      // compute fields and print the date
      cal.computeFields();
      System.out.println("" + cal.getTime());
   }
}