SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date dBegin = sdf.parse("2018-01-01");
Date dEnd = sdf.parse("2019-01-01");
List<String> datas = findDates(dBegin, dEnd);

 

public List<String> findDates(Date dBegin, Date dEnd){
List<String> lDate = new ArrayList<String>();
SimpleDateFormat sd = new SimpleDateFormat("yyyyMMdd hh:mm:ss");
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;
}