标签:seda class time 日期 compare mat 之间 instance get
/** * 获取2个日期之间的月份 * @param beginDate * @param endDate * @param dateList * @return */ public static List<Date> getDifferentMonthBetweenDate(Date beginDate, Date endDate, List<Date> dateList) { beginDate = DateTimeUtil.parseDatetime2Date(beginDate); endDate = DateTimeUtil.parseDatetime2Date(endDate); if (DateTimeUtils.compareDate(beginDate, endDate) == 1) { return null; } Calendar beginCal = Calendar.getInstance(); beginCal.setTime(beginDate); Calendar endCal = Calendar.getInstance(); endCal.setTime(endDate); while (DateTimeUtils.compareDate(beginCal.getTime(), endCal.getTime()) < 1) { dateList.add(beginCal.getTime()); beginCal.add(Calendar.MONTH, 1); } return dateList; }
/**
* dateTime 转化为 date
* @param date
* @return
*/
public static Date parseDatetime2Date(Date date) {
return DateTimeUtils.parseStrToDate(DateTimeUtils.formateDateToStr(date, DateTimeUtils.FORMAT_YMD),
DateTimeUtils.FORMAT_YMD);
}
标签:seda class time 日期 compare mat 之间 instance get
原文地址:https://www.cnblogs.com/stromgao/p/12212969.html