Here you can find the source of getLastDayOfMonth(int year, int month)
public static Date getLastDayOfMonth(int year, int month)
//package com.java2s; //License from project: LGPL import java.util.Calendar; import java.util.Date; public class Main { public static Date getLastDayOfMonth(int year, int month) { Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, month - 1); c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH)); c.set(Calendar.HOUR, 0);//w w w .ja v a 2s .c o m c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); } }