Here you can find the source of getDaysOfMonth(Date date)
public static int getDaysOfMonth(Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int getDaysOfMonth(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);//from w ww .j a v a 2s .co m return c.getActualMaximum(5); } public static int getDaysOfMonth(Date startMonth, Integer monthSeq) { Date month = getMonthByOffset(startMonth, monthSeq.intValue() - 1); return getDaysOfMonth(month); } public static Date getMonthByOffset(Date date, int offset) { Calendar calendar = Calendar.getInstance(); if (null != date) { calendar.setTime(date); calendar.set(5, 1); calendar.set(11, 0); calendar.set(12, 0); calendar.set(13, 0); calendar.set(14, 0); } calendar.add(2, offset); return calendar.getTime(); } }