Java.util.GregorianCalendar.computeTime() 方法


Java.util.GregorianCalendar.computeTime() 方法

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 time and print the date
      cal.computeTime();
      System.out.println("" + cal.getTime());
   }
}