Here you can find the source of getLastDayOfMonth(Date now)
Parameter | Description |
---|---|
now | a parameter |
public static Date getLastDayOfMonth(Date now)
//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(); } }