Java Calendar getActualMaximum方法


Java Calendar getActualMaximum方法

package com.codingdict;

import java.util.*;

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

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

      // get the maximum value that year field can have
      int i = cal.getActualMaximum(Calendar.YEAR);
      System.out.println("Maximum year:" + i);

      // get the maximum value that month field can have
      int a = cal.getActualMaximum(Calendar.MONTH);
      System.out.println("Maximum month:" + a);
   }
}