/**
* 得到两个日期之间所有的日期
*
* @param begin 开始日期
* @param end 结束日期
* @return List<Date> 返回日期的List集合
*/
public static List<Date> getBetweenDates(String beginStr, String endStr) {
SimpleDateFormat sdf = new SimpleDateFormat(dayFormat);
Date begin = null;
Date end = null;
try {
begin = sdf.parse(beginStr);
end = sdf.parse(endStr);
} catch (ParseException e) {
throw new BusinessException(CodeUtil.FAIL, "日期格式转换失败" + e.getMessage());
}
List<Date> result = new ArrayList<Date>();
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(begin);
while (begin.getTime() <= end.getTime()) {
result.add(tempStart.getTime());
tempStart.add(Calendar.DAY_OF_YEAR, 1);
begin = tempStart.getTime();
}
return result;
}
说明:dayFormat为定义的日期格式类型如:yyyy-MM-dd