Here you can find the source of getLastDay(Date date)
public static Date getLastDay(Date date)
//package com.java2s; //License from project: Apache License import java.sql.Date; import java.util.Calendar; public class Main { /**/*from w w w .ja v a 2s . c o m*/ * * get the last date of the month * @param date * @return * Date * @throws */ public static Date getLastDay(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.MONTH, 1); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.DAY_OF_MONTH, -1); Date date2 = new Date(calendar.getTimeInMillis()); return date2; } }