Calendar class inherits from Java.util.calendar.
is base abstract class, that is used for converting between a
object and a set of integer fields such as
Date object specific
instant in time with millisecond.
In this Tutorial we want to describe you a code that helps you in getting the last day of the month. For this we have a class name MonthDaysExample.Inside the main method the calendar call the get Instance method ( ) returns you the calendar object with a specific time zone and locale. we declared and initialized a int variable year, month and date.
1)calendar.set( ) -This method set the field for year, month and date.
2)getActualMaximum( )- This method Return the maximum value for this field, given the current date and store its value int variable max day.
The println print the Max Day from the int variable max day of max day of month February 2009.
In the same way we print the Max day of February 2004 in this code.MonthDaysExample.java
Recommend the tutorial