Java Calendar - getLeastMaximum() Method
The java.util.Calendar.getLeastMaximum() method returns the lowest maximum value for the given calendar field of this Calendar instance. The lowest maximum value is defined as the smallest value returned by getActualMaximum(int) for any possible time value. The least maximum value depends on calendar system specific parameters of the instance.
Syntax
public abstract 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.Calendar.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 Calendar 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(Calendar.DAY_OF_MONTH); System.out.println("Least Maximum for DAY_OF_MONTH: " + mon); //printing the least maximum value for year int yr = Cal.getLeastMaximum(Calendar.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 - Calendar