Java.util.GregorianCalendar.get GreatestMinimum(int field) 方法示例


Java.util.GregorianCalendar.get GreatestMinimum(int field) 方法示例

package com.codingdict;

import java.util.*;

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

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

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

      // get greatest minimum for day_of_month
      int min = cal.getGreatestMinimum(GregorianCalendar.DAY_OF_MONTH);
      System.out.println("Greatest Minimum:" + min);

      // get greatest minimum for YEAR
      min = cal.getGreatestMinimum(GregorianCalendar.YEAR);
      System.out.println("Greatest Minimum:" + min);
   }
}