Java Utility Library

Java GregorianCalendar - getGreatestMinimum() Method



The java.util.GregorianCalendar.getGreatestMinimum() method returns the highest minimum value for the given calendar field of this GregorianCalendar instance. The highest minimum value is defined as the largest value returned by getActualMinimum(int) for any possible time value, taking into consideration the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, getGregorianChange and getTimeZone methods.

Syntax

public int getGreatestMinimum(int field)

Parameters

field Specify the calendar field.

Return Value

Returns the highest minimum value for the given calendar field.

Exception

NA

Example:

In the example below, the java.util.GregorianCalendar.getGreatestMinimum() method returns the highest 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 greatest minimum value for day_of_month
    int mon = Cal.getGreatestMinimum(GregorianCalendar.DAY_OF_MONTH);
    System.out.println("Greatest Minimum for DAY_OF_MONTH: " + mon);

    //printing the greatest minimum value for year
    int yr = Cal.getGreatestMinimum(GregorianCalendar.YEAR);
    System.out.println("Greatest Minimum for YEAR: " + yr);
  }
}

The output of the above code will be:

The Calendar is: Wed Nov 25 00:00:00 GMT 2015
Greatest Minimum for DAY_OF_MONTH: 1
Greatest Minimum for YEAR: 1

❮ Java.util - GregorianCalendar