判断某个日期是不是该月的第一天或最后一天
/** * 判断该日期是否是该月的第一天 * * @param date * 需要判断的日期 * @return */ public boolean isFirstDayOfMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); System.out.println(calendar.get(Calendar.MONTH)); return calendar.get(Calendar.DAY_OF_MONTH) == 1;
}
/**
* 判断该日期是否是该月的最后一天
*
* @param date
* 需要判断的日期
* @return
*/
public boolean isLastDayOfMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(Calendar.DAY_OF_MONTH) == calendar
.getActualMaximum(Calendar.DAY_OF_MONTH);
}