Java Utililty Methods Month End

List of utility methods to do Month End

Description

The list of methods to do Month End are organized into topic(s).

Method

DateendOfMonth(Date date)
end Of Month
if (date == null) {
    return date;
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);
...
DateendOfMonth(Date date)
Returns the final day of the given month of the given year.
Calendar cal = new GregorianCalendar();
cal.setTime(date);
int maxDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, maxDay);
return cal.getTime();
DategetEndOfMonth(Date date)
Gets the end of month.
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);
...
DategetEndOfMonth(Date dt)
Return the End (last day of year) of the given Date Hour, minutes, seconds are set to 23:59:59
if (dt == null)
    return null;
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(getStartOfMonth(dt));
gc.add(Calendar.MONTH, 1);
gc.add(Calendar.DATE, -1);
gc.set(Calendar.HOUR_OF_DAY, 23);
gc.set(Calendar.MINUTE, 59);
...
longgetEndOfMonth(long date)
Returns the date corresponding to the end of the month.
return getMonth(date, 1);