Here you can find the source of endOfMonth(Date date)
public static Date endOfMonth(Date date)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static Date endOfMonth(Date date) { if (date == null) { return date; }/*ww w .j ava 2 s.c o m*/ Date start = newDate(date.getYear(), date.getMonth(), 1, 0, 0, 0); Calendar cal = Calendar.getInstance(); cal.setTime(start); cal.add(Calendar.MONTH, 1); cal.add(Calendar.SECOND, -1); return cal.getTime(); } /** * * @param year * @param month * @param day * @param hour * @param minute * @param sencond * @return */ public static Date newDate(int year, int month, int day, int hour, int minute, int sencond) { if (month >= 1) { month = month - 1; } return new Date(year + 1900, month, day, hour, minute, sencond); } }