Here you can find the source of getMonthHaveDays(int year, int month)
public static int getMonthHaveDays(int year, int month)
//package com.java2s; import java.util.Calendar; public class Main { public static int getMonthHaveDays(int year, int month) { Calendar cal = Calendar.getInstance(); cal.set(year, month - 1, 1);// www . ja va2 s. com return cal.getActualMaximum(Calendar.DATE); } }