Java日历Calendar clear方法


Java日历Calendar clear方法

package com.codingdict;

import java.util.*;

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

      // create a calendar
      Calendar cal = Calendar.getInstance();

      // display the current date and time
      System.out.println("Current Calendar Date: " + cal.getTime());

      // use clear method to set year as undefined.
      cal.clear(Calendar.YEAR);

      // print the result
      System.out.println("The calendar shows : " + cal.getTime());

      // use clear method to set month as undefined.
      cal.clear(Calendar.MONTH);

      // print the result
      System.out.println("The calendar shows : " + cal.getTime());
   }
}