Here you can find the source of getLastDayOfMonth(int year, int month)
public static int getLastDayOfMonth(int year, int month)
//package com.java2s; import java.util.Calendar; public class Main { public static int getLastDayOfMonth(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, 1); int value = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.set(Calendar.DAY_OF_MONTH, value); return calendar.get(Calendar.DAY_OF_MONTH); }/*from w w w . j ava 2 s. c om*/ }