Here you can find the source of daysInMonth(final int year, final int month)
Parameter | Description |
---|---|
year | Year. |
month | Month. |
public static int daysInMonth(final int year, final int month)
//package com.java2s; // and/or modify it under the terms of the GNU General Public License import java.util.Calendar; public class Main { /**//from w ww . j a va2s .co m * Get the number of days in that month. * * @param year * Year. * @param month * Month. * @return Number of days in month. */ public static int daysInMonth(final int year, final int month) { Calendar cal = Calendar.getInstance(); cal.set(year, month, 1); return cal.getActualMaximum(Calendar.DAY_OF_MONTH); } }