Java GregorianCalendar - getMinimum() Method
The java.util.GregorianCalendar.getMinimum() method returns the minimum value for the given calendar field of this GregorianCalendar instance. The minimum value is defined as the smallest value returned by the get method for any possible time value, taking into consideration the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, getGregorianChange and getTimeZone methods.
Syntax
public int getMinimum(int field)
Parameters
field |
Specify the calendar field. |
Return Value
Returns the minimum value for the given calendar field.
Exception
NA
Example:
In the example below, the java.util.GregorianCalendar.getMinimum() method returns the minimum 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 GregorianCalendar Cal = new GregorianCalendar(2015, 10, 25); //printing the Calendar System.out.println("The Calendar is: " + Cal.getTime()); //printing the minimum value for day_of_month int mon = Cal.getMinimum(GregorianCalendar.DAY_OF_MONTH); System.out.println("Minimum for DAY_OF_MONTH: " + mon); //printing the minimum value for year int yr = Cal.getMinimum(GregorianCalendar.YEAR); System.out.println("Minimum for YEAR: " + yr); } }
The output of the above code will be:
The Calendar is: Wed Nov 25 00:00:00 UTC 2015 Minimum for DAY_OF_MONTH: 1 Minimum for YEAR: 1
❮ Java.util - GregorianCalendar