Java Date Time - Java Calendar.getActualMaximum(int field)








Syntax

Calendar.getActualMaximum(int field) has the following syntax.

public int getActualMaximum(int field)

Example

In the following code shows how to use Calendar.getActualMaximum(int field) method.

/*  ww  w  .  j  ava  2s. c o  m*/

import java.util.Calendar;

public class Main {

   public static void main(String[] args) {

      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);
   }
}

The code above generates the following result.