Java Calendar.getLeastMaximum(int field)

Syntax

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

public abstract int getLeastMaximum(int field)

Example

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


/*from w w w. j a v  a  2  s . c  o m*/

import java.util.Calendar;

public class Main {

   public static void main(String[] args) {

      Calendar cal = Calendar.getInstance();

      // get the days required in the first week of the year
      System.out.println("Months required: " + cal.get(Calendar.MONTH));

      // print the lowest maximum months for year.
      int max = cal.getLeastMaximum(Calendar.MONTH);
      System.out.println("Lowest maximum months :" + max);

   }
}

The code above generates the following result.