Java Calendar.getMaximum(int field)

Syntax

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

public abstract int getMaximum(int field)

Example

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


//  w w  w  . ja v a  2 s.c  o  m


import java.util.Calendar;

public class Main {

   public static void main(String[] args) {

      Calendar cal = Calendar.getInstance();

      // return the maximum value for days
      int max = cal.getMaximum(Calendar.DAY_OF_WEEK);
      System.out.println("Maximum days  :" + max);

      // return the maximum value for months
      max = cal.getMaximum(Calendar.MONTH);
      System.out.println("Maximum months  :" + max);
   }
}

The code above generates the following result.