The getLeastMaximum(int calndr_field) method in Calendar class is used to return the lowest maximum value for the given calendar field(int calndr_field) of this Calendar instance.
Syntax:
public abstract int getLeastMaximum(int calndr_field)
Parameters: The method takes one parameter calndr_field that refers to the calendar field which is to be operated upon.
Return Value: The method returns the lowest maximum value of this calendar field.
Below programs illustrate the working of getLeastMaximum() Method of Calendar class:
Example 1:
// Java code to illustrate // getLeastMaximum() method import java.util.*; public class Calendar_Demo { public static void main(String args[]) { // Creating a calendar Calendar calndr = Calendar.getInstance(); // Getting the required months System.out.println("Required Months: " + calndr.get(Calendar.MONTH)); // Getting the lowest maximum month int low_max = calndr.getLeastMaximum(Calendar.MONTH); // Displaying the results System.out.println("The Lowest" + " Maximum months: " + low_max); } } |
Required Months: 1 The Lowest Maximum months: 11
Example 2:
// Java code to illustrate // getLeastMaximum() method import java.util.*; public class Calendar_Demo { public static void main(String args[]) { // Creating a calendar Calendar calndr = new GregorianCalendar(2018, 6, 10); // Getting the required months System.out.println("Required Months: " + calndr.get(Calendar.MONTH)); // Getting the lowest maximum month int low_max = calndr.getLeastMaximum(Calendar.MONTH); // Displaying the results System.out.println("The Lowest" + " Maximum months: " + low_max); } } |
Required Months: 6 The Lowest Maximum months: 11
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getLeastMaximum-int-
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- GregorianCalendar getLeastMaximum() Method in Java
- Calendar clone() Method in Java with Examples
- Calendar clear() Method in Java with Examples
- Calendar add() Method in Java with Examples
- Calendar toString() Method in Java with Examples
- Calendar compareTo() Method in Java with Examples
- Calendar complete() Method in Java with Examples
- Calendar computeTime() method in Java with Examples
- Calendar computeFields() method in Java with Examples
- Calendar get() method in Java with Examples
- Calendar getActualMinimum() Method in Java with Examples
- Calendar getActualMaximum() Method in Java with Examples
- Calendar getAvailableLocales() Method in Java with Examples
- Calendar getDisplayName() Method in Java with Examples
- Calendar getDisplayNames() Method in Java with Examples
- Calendar getFirstDayOfWeek() Method in Java with Examples
- Calendar getGreatestMinimum() Method in Java with Examples
- Calendar getInstance() Method in Java with Examples
- Calendar getMaximum() method in Java with Examples
- Calendar getMinimalDaysInFirstWeek() Method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

