Java.util.Calendar.getGreatestMinimum() Method


Description

The java.util.Calendar.getGreatestMinimum() method returns the highest minimum value for the given calendar field of this Calendar instance.

Declaration

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

public abstract int getGreatestMinimum(int field)

Parameters

field − the given calendar field.

Return Value

Returns lowest maximum value of the given calendar field.

Exception

NA

Example

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

package com.tutorialspoint;

import java.util.*;

public class CalendarDemo {
   public static void main(String[] args) {

      // create a calendar    
      Calendar cal = new GregorianCalendar(2010, 9, 15);

      // print the greatest min. for year field
      int result = cal.getGreatestMinimum(Calendar.YEAR);
      System.out.println("The minimum is: " + result);
   }
}

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

The minimum is: 1
java_util_calendar.htm
Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements