输入格式:
public List<String> getEndDay(String beginDate,String endDate) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date dBegin = sdf.parse(beginDate);
Date dEnd = sdf.parse(endDate);
List<String> datas = findDates(dBegin, dEnd);
return datas;
}
public List<String> findDates(Date dBegin, Date dEnd){
List<String> lDate = new ArrayList<String>();
SimpleDateFormat sd = new SimpleDateFormat("yyyyMMdd");
lDate.add(sd.format(dBegin));
Calendar calBegin = Calendar.getInstance();
// 使用给定的 Date 设置此 Calendar 的时间
calBegin.setTime(dBegin);
Calendar calEnd = Calendar.getInstance();
// 使用给定的 Date 设置此 Calendar 的时间
calEnd.setTime(dEnd);
// 测试此日期是否在指定日期之后
while (dEnd.after(calBegin.getTime()))
{
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
calBegin.add(Calendar.DAY_OF_MONTH, 1);
lDate.add(sd.format(calBegin.getTime()));
}
return lDate;
}