The java.util.GregorianCalendar.getMaximum() method is an in-built function in Java which returns the maximum value for the particular calendar field passed as parameter to the function. For any possible time value, it is the highest value that the get() method returns, considering the current values of the getFirstDayOfWeek(), getMinimalDaysInFirstWeek(), getGregorianChange() and getTimeZone() methods as well.
public int getMaximum(int calendarfield)
Parameters: This function accepts one mandatory parameter calendarfield whose maximum value for this GregorianCalender instance will be returned by the function.
Return Value: This method returns the maximum value of the specified calendar field for this GregorianCalender instance.
Input : DAY_OF_MONTH Output : 31 Input : WEEK_OF_MONTH Output : 6
Below programs illustrate the java.util.GregorianCalendar.getMaximum() function:
Current Date and Time : Fri Jul 27 12:44:38 UTC 2018 Maximum for WEEK_OF_MONTH field :6 Maximum for DAY_OF_MONTH field:31
Current Date and Time : Fri Jul 27 12:44:40 UTC 2018 Maximum for YEAR field :292278994 Maximum for HOUR_OF_DAY field:23
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.