Java Utility Library

Java Calendar - getGreatestMinimum() Method



The java.util.Calendar.getGreatestMinimum() method returns the highest minimum value for the given calendar field of this Calendar instance. The highest minimum value is defined as the largest value returned by getActualMinimum(int) for any possible time value. The greatest minimum value depends on calendar system specific parameters of the instance.

Syntax

public abstract 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.Calendar.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
    Calendar 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(Calendar.DAY_OF_MONTH);
    System.out.println("Greatest Minimum for DAY_OF_MONTH: " + mon);

    //printing the greatest minimum value for year
    int yr = Cal.getGreatestMinimum(Calendar.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 UTC 2015
Greatest Minimum for DAY_OF_MONTH: 1
Greatest Minimum for YEAR: 1

❮ Java.util - Calendar