Skip to content

Commit 4d6e965

Browse files
Fix the bug in parse date to int when year out of range
1 parent 3eea99d commit 4d6e965

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

java/tsfile/src/main/java/org/apache/tsfile/utils/DateUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static Integer parseDateExpressionToInt(String dateExpression) {
4848
throw new DateTimeParseException(
4949
"Invalid date format. Please use YYYY-MM-DD format.", dateExpression, 0);
5050
}
51-
if (date.getYear() < 1000) {
51+
if (date.getYear() < 1000 || date.getYear() > 9999) {
5252
throw new DateTimeParseException("Year must be between 1000 and 9999.", dateExpression, 0);
5353
}
5454
return date.getYear() * 10000 + date.getMonthValue() * 100 + date.getDayOfMonth();
@@ -58,7 +58,7 @@ public static Integer parseDateExpressionToInt(LocalDate localDate) {
5858
if (localDate == null) {
5959
throw new DateTimeParseException("Date expression is null or empty.", "", 0);
6060
}
61-
if (localDate.getYear() < 1000) {
61+
if (localDate.getYear() < 1000 || localDate.getYear() > 9999) {
6262
throw new DateTimeParseException(
6363
"Year must be between 1000 and 9999.", localDate.format(DATE_FORMATTER), 0);
6464
}

0 commit comments

Comments
 (0)