Here you can find the source of getMonthDays(Integer year, Integer month)
public static Integer getMonthDays(Integer year, Integer month)
//package com.java2s; import java.util.*; public class Main { public static Integer getMonthDays(Integer year, Integer month) { if (year != null && year > 0 && month != null && month > 0) { Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, month); c.set(Calendar.DATE, 1); c.add(Calendar.DATE, -1); return c.get(Calendar.DATE); }//from w w w .jav a 2 s. c om return 0; } }