/**
* 从大到小
*/
public List<LocalDate> getDescDateList(LocalDate startDate,LocalDate endDate) {
long size = endDate.toEpochDay() - startDate.toEpochDay();
if (size < 0) {
return Collections.emptyList();
}
// 初始化大小防止list频繁扩容
List<LocalDate> result = new ArrayList<>((int)size);
for (int i = 0; i < size ; i ++) {
result.add(endDate);
endDate = endDate.plusDays(-1);
}
return result;
}
/**
* 从小到大
*/
public List<LocalDate> getAscDateList(LocalDate startDate,LocalDate endDate) {
long size = endDate.toEpochDay() - startDate.toEpochDay();
if (size < 0) {
return Collections.emptyList();
}
// 初始化大小防止list频繁扩容
List<LocalDate> result = new ArrayList<>((int)size);
for (int i = 0; i < size ; i ++) {
result.add(startDate);
startDate = startDate.plusDays(1);
}
return result;
}
获取俩个LocalDate中间所有的日期
于 2019-09-04 10:54:50 首次发布