Calendar getLeastMaximum() method in Java with Examples
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:
import java.util.*;
public class Calendar_Demo {
public static void main(String args[])
{
Calendar calndr = Calendar.getInstance();
System.out.println( "Required Months: "
+ calndr.get(Calendar.MONTH));
int low_max = calndr.getLeastMaximum(Calendar.MONTH);
System.out.println( "The Lowest"
+ " Maximum months: " + low_max);
}
}
|
Output:
Required Months: 1
The Lowest Maximum months: 11
Example 2:
import java.util.*;
public class Calendar_Demo {
public static void main(String args[])
{
Calendar calndr = new GregorianCalendar( 2018 , 6 , 10 );
System.out.println( "Required Months: "
+ calndr.get(Calendar.MONTH));
int low_max = calndr.getLeastMaximum(Calendar.MONTH);
System.out.println( "The Lowest"
+ " Maximum months: " + low_max);
}
}
|
Output:
Required Months: 6
The Lowest Maximum months: 11
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getLeastMaximum-int-
Last Updated :
19 Feb, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...