chetan chetan - 9 months ago 53
Java Question

Find the number of days in a month in Java

How do you find the number of days in a month in Java?

Answer

Set the year and month on a Calendar object and then use getActualMaximum to return the last day:

calendar.getActualMaximum(Calendar.DAY_OF_MONTH)