GregorianCalendar class getMaximum(int field) method example
Returns the maximum value for the given calendar field of this GregorianCalendar instance.
GregorianCalendarclass getMaximum(int field)method example. This example shows you how to use getMaximum(int field)method.This method Returns the maximum value for the given calendar field of this GregorianCalendar instance.
Here is the code:-
/**
* @Program that Returns the maximum value for the given calendar field
* GetMaximum.java
* Author:-RoseIndia Team
* Date:-27-May-2008
*/
import java.util.*;
public class GetMaximum {
public static void main(String[] args) {
//Creating a Calendar
GregorianCalendar g = new GregorianCalendar(2004, 6, 3);
//Displays the date of the Calendar
System.out.println("Current date of the Calendar is: " + g.get(Calendar.DATE));
//Returns the maximum value for the given calendar field
int i = g.getMaximum(Calendar.DATE);
System.out.println("Maximum value for the given calendar field is:" + i);
}
} |
Output of the program:-
Current date of the Calendar is: 3
Maximum value for the given calendar field is:31 |
|