java.util.Calendar getGreatestMinimum(int field)

Description :

This java tutorial shows how to use the getMaximum(int field) method of Calendar class of java.util package. This 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.

Method Syntax :

public abstract int getGreatestMinimum(int field)

Parameter Input :

 

DataType Parameter Description
int field the calendar field we want to get the highest minimum value

 

Method Returns :

This method returns int which corresponds to the highest minimum value for the given calendar field.

Compatibility Version :

Requires Java 1.1 and up

Exception :

N/A

Java Code Example :

This java example source code demonstrates the use of getGreatestMinimum(int field) method of Calendar class. This example java code simply prints the greatest minimum values for some of the Calendar fields.

package com.javatutorialhq.java.examples;

import java.util.Calendar;

/*
 * This example source code demonstrates the use of  
 * getGreatestMinimum(int field) of Calendar class
 */

public class CalendarGetGreatestMinimumExample {

	public static void main(String[] args){

		Calendar cal = Calendar.getInstance();
		System.out.println("Time:" + cal.getTime());		
		int greatestMinYear = cal.getGreatestMinimum(Calendar.YEAR);
		int greatestMinMonth = cal.getGreatestMinimum(Calendar.MONTH);
		int greatestMinWeek = cal.getGreatestMinimum(Calendar.WEEK_OF_YEAR);
		int greatestMinDate = cal.getGreatestMinimum(Calendar.DATE);
		
		System.out.println("Greatest Minimum Year:"+greatestMinYear);
		System.out.println("Greatest Minimum Month:"+greatestMinMonth);
		System.out.println("Greatest Minimum Week of Year:"+greatestMinWeek);
		System.out.println("Greatest Minimum Date:"+greatestMinDate);
		
	}
}

Sample Output :

Running the getGreatestMinimum(int field) method example source code of Calendar class will give you the following output:

Calendar getGreatestMinimum(int field) method example

Calendar getGreatestMinimum(int field) method example

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :