Here you can find the source of getMonthDays(Integer year, Integer month)
public static int getMonthDays(Integer year, Integer month)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static int getMonthDays(Integer year, Integer month) { Calendar c = Calendar.getInstance(); c.set(year, month - 1, 1);//from w ww. jav a2 s. c om return c.getActualMaximum(Calendar.DAY_OF_MONTH); } }