Here you can find the source of getEndOfMonth(Date date)
Parameter | Description |
---|---|
date | to get the end of month for |
public static Date getEndOfMonth(Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { /**// ww w . j av a 2 s . c o m * Gets the end of month. * * @param date to get the end of month for * @return last day of month. */ public static Date getEndOfMonth(Date date) { if (null == date) { date = new Date(); } Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.MONTH, 1); calendar.add(Calendar.DATE, -1); return calendar.getTime(); } }