Java日历 GregorianCalendar complete方法


Java日历 GregorianCalendar complete方法

package com.codingdict;

import java.util.*;

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

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

      // print the current date
      System.out.println("The current date is : " + cal.getTime());

      // clear the calendar
      cal.clear();

      // set a new year and call complete()
      cal.set(GregorianCalendar.YEAR, 1998);
      cal.complete();

      // print the current date
      System.out.println("New date is : " + cal.getTime());
   }
}