Here you can find the source of daysInMonth(Calendar c)
public static int daysInMonth(Calendar c)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.GregorianCalendar; public class Main { public static int daysInMonth(int day, int month, int year) { return new GregorianCalendar(year, month, day) .getActualMaximum(Calendar.DAY_OF_MONTH); }//from w ww .j a va 2 s . c o m public static int daysInMonth(Calendar c) { return daysInMonth(c.get(Calendar.DATE), c.get(Calendar.MONTH), c.get(Calendar.YEAR)); } }