解决测值查询有重复日期数据问题
parent
826576c3e1
commit
5a4d97234d
|
|
@ -197,13 +197,16 @@ public class DateUtil {
|
||||||
public static List<String> getDatesBetween(Date startDate, Date endDate,Boolean isDesc) {
|
public static List<String> getDatesBetween(Date startDate, Date endDate,Boolean isDesc) {
|
||||||
List<String> dates = new ArrayList<>();
|
List<String> dates = new ArrayList<>();
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
while (startDate.getTime()<=endDate.getTime()){
|
||||||
|
// 把日期添加到集合
|
||||||
|
dates.add(convertDateToString(startDate));
|
||||||
|
// 设置日期
|
||||||
calendar.setTime(startDate);
|
calendar.setTime(startDate);
|
||||||
|
//把日期增加一天
|
||||||
while (calendar.getTime().before(endDate)) {
|
|
||||||
dates.add(convertDateToString(calendar.getTime()));
|
|
||||||
calendar.add(Calendar.DATE, 1);
|
calendar.add(Calendar.DATE, 1);
|
||||||
|
// 获取增加后的日期
|
||||||
|
startDate=calendar.getTime();
|
||||||
}
|
}
|
||||||
dates.add(convertDateToString(endDate));
|
|
||||||
if(isDesc){
|
if(isDesc){
|
||||||
return dates.reversed();
|
return dates.reversed();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue