Java.util.GregorianCalendar.get GreatestMinimum(int field) Method Example



The java.util.GregorianCalendar.getGreatestMinimum(int field) 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.


Following is the declaration for java.util.GregorianCalendar.getGreatestMinimum() method

public int getGreatestMinimum(int field)


  • field -- the calendar field

Return Value

This method returns the highest minimum value for the given calendar field.


  • NA


The following example shows the usage of java.util.GregorianCalendar.getGreatestMinimum() method.

package com.tutorialspoint;

import java.util.*;

public class GregorianCalendarDemo {

   public static void main(String[] args) {

   // create a new calendar
   GregorianCalendar cal = 
   (GregorianCalendar) GregorianCalendar.getInstance();

   // print the current date and time
   System.out.println("" + cal.getTime());

   // get greatest minimum for day_of_month
   int min = cal.getGreatestMinimum(GregorianCalendar.DAY_OF_MONTH);
   System.out.println("Greatest Minimum:" + min);

   // get greatest minimum for YEAR
   min = cal.getGreatestMinimum(GregorianCalendar.YEAR);
   System.out.println("Greatest Minimum:" + min);


Let us compile and run the above program, this will produce the following result:

Fri May 18 02:52:57 EEST 2012
Greatest Minimum:1
Greatest Minimum:1