java.util.Calendar getActualMaximum(int field)

Description :

This java tutorial shows how to use the getActualMaximum(int field) method of Calendar class of java.util package. This method returns the maximum value that the specified calendar field could have, given the time value of this Calendar. For example, the actual maximum value of the MONTH field is 12 in some years, and 13 in other years in the Hebrew calendar system.

Method Syntax :

public int getActualMaximum(int field)

Parameter Input :


DataType Parameter Description
int field the calendar field we want to get the actual maximum value


Method Returns :

This method returns int which corresponds to the maximum of the given calendar field for the time value of this Calendar

Compatibility Version :

Requires Java 1.2 and up

Exception :


Java Code Example :

This java example source code demonstrates the use of getActualMaximum(int field) method of Calendar class. This example java code simply prints the actual maximum values for some of the Calendar fields.


import java.util.Calendar;

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

public class CalendarGetActualMaximumExample {

	public static void main(String[] args){

		Calendar cal = Calendar.getInstance();
		System.out.println("Time:" + cal.getTime());		
		int actualMaxYear = cal.getActualMaximum(Calendar.YEAR);
		int actualMaxMonth = cal.getActualMaximum(Calendar.MONTH);
		int actualMaxWeek = cal.getActualMaximum(Calendar.WEEK_OF_YEAR);
		int actualMaxDate = cal.getActualMaximum(Calendar.DATE);
		System.out.println("Actual Maximum Year:"+actualMaxYear);
		System.out.println("Actual Maximum Month:"+actualMaxMonth);
		System.out.println("Actual Maximum Week of Year:"+actualMaxWeek);
		System.out.println("Actual Maximum Date:"+actualMaxDate);

Sample Output :

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

Time:Thu Feb 12 22:58:44 CST 2015
Actual Maximum Year:292278994
Actual Maximum Month:11
Actual Maximum Week of Year:52
Actual Maximum Date:28

Exception Scenario :


Similar Method :

  • N/A

Suggested Reading List :

References :