Calendar getGreatestMinimum() Method in Java with Examples
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:
// Java code to illustrate // getGreatestMinimum() method import java.util.*; public class Java_Calendar_Demo { public static void main(String[] args) { // Creating a calendar Calendar calndr = new GregorianCalendar(2018, 6, 10); // Calculating the highest min value int rslt = calndr.getGreatestMinimum(Calendar.YEAR); // Displaying the highest min value System.out.println("The minimum year is: " + rslt); } } |
The minimum year is: 1
Example 2:
// Java code to illustrate // getGreatestMinimum() method import java.util.*; public class Java_Calendar_Demo { public static void main(String[] args) { // Creating a calendar Calendar calndr = Calendar.getInstance(); // Calculating the highest min value int rslt = calndr.getGreatestMinimum(Calendar.MONTH); // Displaying the highest min value System.out.println("The minimum month is: " + rslt); } } |
The minimum month is: 0
Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#getGreatestMinimum(int)
Recommended Posts:
- GregorianCalendar getGreatestMinimum() Method in Java
- Calendar set() Method in Java with Examples
- Calendar add() Method in Java with Examples
- Calendar get() method in Java with Examples
- Calendar compareTo() Method in Java with Examples
- Calendar roll() Method in Java with Examples
- Calendar setFirstDayOfWeek() Method in Java with Examples
- Calendar setLenient() Method in Java with Examples
- Calendar getMinimum() Method in Java with Examples
- Calendar internalGet() Method in Java with Examples
- Calendar getTimeInMillis() Method in Java with Examples
- Calendar isLenient() Method in Java with Examples
- Calendar hashCode() Method in Java with Examples
- Calendar complete() Method in Java with Examples
- Calendar getMaximum() 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.

