Java GregorianCalendar - getLeastMaximum() Method
The java.util.GregorianCalendar.getLeastMaximum() method returns the lowest maximum value for the given calendar field of this GregorianCalendar instance. The lowest maximum value is defined as the smallest value returned by getActualMaximum(int) for any possible time value, taking into consideration the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, getGregorianChange and getTimeZone methods.
Syntax
public int getLeastMaximum(int field)
Parameters
field |
Specify the calendar field. |
Return Value
Returns the lowest maximum value for the given calendar field.
Exception
NA
Example:
In the example below, the java.util.GregorianCalendar.getLeastMaximum() method returns the lowest maximum value for the given calendar field.
import java.util.*; public class MyClass { public static void main(String[] args) { //creating a Calendar object with specified date GregorianCalendar Cal = new GregorianCalendar(2015, 10, 25); //printing the Calendar System.out.println("The Calendar is: " + Cal.getTime()); //printing the least maximum value for day_of_month int mon = Cal.getLeastMaximum(GregorianCalendar.DAY_OF_MONTH); System.out.println("Least Maximum for DAY_OF_MONTH: " + mon); //printing the least maximum value for year int yr = Cal.getLeastMaximum(GregorianCalendar.YEAR); System.out.println("Least Maximum for YEAR: " + yr); } }
The output of the above code will be:
The Calendar is: Wed Nov 25 00:00:00 UTC 2015 Least Maximum for DAY_OF_MONTH: 28 Least Maximum for YEAR: 292269054
❮ Java.util - GregorianCalendar