Java.util.Calendar.getLeastMaximum() Method


Advertisements


Description

The java.util.Calendar.getLeastMaximum()() method returns the lowest maximum value for the given calendar field of this Calendar instance.

Declaration

Following is the declaration for java.util.Calendar.getLeastMaximum()() method

public abstract int getLeastMaximum()(field)

Parameters

field − the given calendar field.

Return Value

Returns lowest maximum value of the given calendar field.

Exception

NA

Example

The following example shows the usage of java.util.calendar.getLeastMaximum() method.

Live Demo
package com.tutorialspoint;

import java.util.*;

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

      // create a calendar
      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);
   }
}

Let us compile and run the above program, this will produce the following result −

Months required: 4
Lowest maximum months :11

java_util_calendar.htm

Advertisements