public static List<String> getDate(Date startDate, Date endDate){标签:startDate,getTime,所有,list,日期,时间段,计算,calendar,Calendar From: https://www.cnblogs.com/Ifyou/p/17051279.html
//定义时间格式
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<String> list = new ArrayList<>();
// 转化成日期类型
//用Calendar 进行日期比较判断
Calendar calendar = Calendar.getInstance();
while (startDate.getTime()<=endDate.getTime()){
// 把日期添加到集合
list.add(simpleDateFormat.format(startDate));
// 设置日期
calendar.setTime(startDate);
//把日期增加一分
calendar.add(Calendar.DAY_OF_MONTH, 1);
// 获取增加后的日期
startDate=calendar.getTime();
}
return list;
}