Java Day of Month getLastDayOfMonth(Date now)

Here you can find the source of getLastDayOfMonth(Date now)

Description

get Last Day Of Month

License

Open Source License

Parameter

Parameter Description
now a parameter

Declaration

public static Date getLastDayOfMonth(Date now) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**// w  w  w .  j a  v a  2 s.co m
     * 
     * @param now
     * @return
     */
    public static Date getLastDayOfMonth(Date now) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(now);
        cal.set(Calendar.DAY_OF_MONTH, 1);
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        cal.set(Calendar.MILLISECOND, 999);
        cal.add(Calendar.MONTH, 1);
        cal.add(Calendar.DATE, -1);
        return cal.getTime();
    }
}

Related

  1. getLastDayOfMonth(Date date)
  2. getLastDayOfMonth(Date date)
  3. getLastDayOfMonth(Date date)
  4. getLastDayOfMonth(Date dt)
  5. getLastDayOfMonth(Date firstDate)
  6. getLastDayOfMonth(Date sDate)
  7. getLastDayOfMonth(final Date date)
  8. getLastdayOfMonth(int month, int year)
  9. getLastDayOfMonth(int year, int month)