mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-05-09 12:04:21 +08:00
fix(common): 解决日期范围解析中的空指针异常
- 在日期范围解析逻辑中添加了空值检查 - 当开始日期或结束日期为空时返回空列表 - 避免了在日期解析失败时可能出现的空指针异常
This commit is contained in:
@@ -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)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user