话不多说,直接上代码!
private static List<String> getDateListOfDateRange(String startDate, String endDate) {
List<String> dateList = new ArrayList<>();
long betweenDay = DateUtil.betweenDay(DateUtil.parse(startDate, "yyyy-MM-dd HH:mm:ss"), DateUtil.parse(endDate, "yyyy-MM-dd HH:mm:ss"), true);
for (int i = 0; i <= betweenDay; i++) {
DateTime dateTime = DateUtil.offsetDay(DateUtil.parse(startDate), i);
dateList.add(DateUtil.format(dateTime, "yyyy-MM-dd"));
}
return dateList;
}