fix(common): 解决日期范围解析中的空指针异常
Some checks are pending
supersonic CentOS CI / build (21) (push) Waiting to run
supersonic mac CI / build (21) (push) Waiting to run
supersonic ubuntu CI / build (21) (push) Waiting to run
supersonic windows CI / build (21) (push) Waiting to run

- 在日期范围解析逻辑中添加了空值检查
- 当开始日期或结束日期为空时返回空列表
- 避免了在日期解析失败时可能出现的空指针异常
This commit is contained in:
jerryjzhang
2026-05-09 10:53:46 +08:00
parent 6f11cdc12c
commit 9f2262c97b

View File

@@ -181,6 +181,11 @@ public class DateUtils {
LocalDate startDate = parseDate(startDateStr); LocalDate startDate = parseDate(startDateStr);
LocalDate endDate = parseDate(endDateStr); LocalDate endDate = parseDate(endDateStr);
List<String> datesInRange = new ArrayList<>(); List<String> datesInRange = new ArrayList<>();
if (startDate == null || endDate == null) {
return datesInRange;
}
LocalDate currentDate = startDate; LocalDate currentDate = startDate;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
while (!currentDate.isAfter(endDate)) { while (!currentDate.isAfter(endDate)) {