Calendar getGreatestMinimum() Method in Java with Examples
Last Updated :
18 Feb, 2019
The getGreatestMinimum(int calndr_field) method in Calendar class is used to return the highest minimum value for the given calendar field(int calndr_field) of this Calendar instance.
Syntax:
public abstract int getGreatestMinimum(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 getGreatestMinimum() Method of Calendar class:
Example 1:
import java.util.*;
public class Java_Calendar_Demo {
public static void main(String[] args)
{
Calendar calndr = new GregorianCalendar( 2018 , 6 , 10 );
int rslt = calndr.getGreatestMinimum(Calendar.YEAR);
System.out.println( "The minimum year is: " + rslt);
}
}
|
Output:
The minimum year is: 1
Example 2:
import java.util.*;
public class Java_Calendar_Demo {
public static void main(String[] args)
{
Calendar calndr = Calendar.getInstance();
int rslt = calndr.getGreatestMinimum(Calendar.MONTH);
System.out.println( "The minimum month is: " + rslt);
}
}
|
Output:
The minimum month is: 0
Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#getGreatestMinimum(int)
Share your thoughts in the comments
Please Login to comment...