The Java Calendar getActualMaximum() method returns the maximum value that the specified calendar field could have, based on the time value of this Calendar.
DeclarationFollowing is the declaration for java.util.Calendar.getActualMaximum() method
public int getActualMaximum(int field)Parameters
field − the given calendar field.
Returns the maximum of the given calendar field.
ExceptionNA
Getting Maximum Year from a Calendar Instance ExampleThe following example shows the usage of Java Calendar getActualMaximum() method. We're creating a Calendar instance of current date. We're printing the maximum possible value of Year.
package com.tutorialspoint; import java.util.Calendar; public class CalendarDemo { public static void main(String[] args) { // create a calendar Calendar cal = Calendar.getInstance(); // get the maximum value that year field can have System.out.println("Maximum year:" + cal.getActualMaximum(Calendar.YEAR)); } }Output
Let us compile and run the above program, this will produce the following result −
Maximum year:292278993Getting Maximum Month from a Calendar Instance Example
The following example shows the usage of Java Calendar getActualMaximum() method. We're creating a Calendar instance of current date. We're printing the maximum possible value of Month.
package com.tutorialspoint; import java.util.Calendar; public class CalendarDemo { public static void main(String[] args) { // create a calendar Calendar cal = Calendar.getInstance(); // get the maximum value that month field can have System.out.println("Maximum month:" + cal.getActualMaximum(Calendar.MONTH)); } }Output
Let us compile and run the above program, this will produce the following result −
Maximum month:11Getting Maximum Day from a Calendar Instance Example
The following example shows the usage of Java Calendar getActualMaximum() method. We're creating a Calendar instance of current date. We're printing the maximum possible value of Day.
package com.tutorialspoint; import java.util.Calendar; public class CalendarDemo { public static void main(String[] args) { // create a calendar Calendar cal = Calendar.getInstance(); // get the maximum value that day field can have System.out.println("Maximum day:" + cal.getActualMaximum(Calendar.DAY_OF_MONTH)); } }Output
Let us compile and run the above program, this will produce the following result −
Maximum day:30
java_util_calendar.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4