Java Utility Library

Java GregorianCalendar - getActualMinimum() Method



The java.util.GregorianCalendar.getActualMinimum() method returns the minimum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, getGregorianChange and getTimeZone methods.

For example, if the Gregorian change date is January 10, 1970 and the date of this GregorianCalendar is January 20, 1970, the actual minimum value of the DAY_OF_MONTH field is 10 because the previous date of January 10, 1970 is December 27, 1996 (in the Julian calendar). Therefore, December 28, 1969 to January 9, 1970 don't exist.

Syntax

public int getActualMinimum(int field)

Parameters

field Specify the calendar field.

Return Value

Returns the minimum of the given field for the time value of this GregorianCalendar.

Exception

NA

Example:

In the example below, the java.util.GregorianCalendar.getActualMinimum() method returns the minimum value for the given field for the given time.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a Calendar object with specified date
    GregorianCalendar Cal = new GregorianCalendar(2015, 1, 25);

    //printing the Calendar
    System.out.println("The Calendar is: " + Cal.getTime());

    //printing the actual minimum value for day_of_month
    int mon = Cal.getActualMinimum(GregorianCalendar.DAY_OF_MONTH);
    System.out.println("Actual Minimum for DAY_OF_MONTH: " + mon);
  }
}

The output of the above code will be:

The Calendar is: Wed Feb 25 00:00:00 GMT 2015
Actual Minimum for DAY_OF_MONTH: 1

❮ Java.util - GregorianCalendar