Skip to content

fix: reject invalid calendar date strings - #1167

Open
Aias00 wants to merge 5 commits into
apache:mainfrom
Aias00:fix/strict-invalid-dates-1157
Open

Aias00 wants to merge 5 commits into
apache:mainfrom
Aias00:fix/strict-invalid-dates-1157

Conversation

@Aias00

@Aias00 Aias00 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of the pull request

Closed: #1157

Default date conversion silently normalized invalid calendar strings instead of reporting malformed input.

What's changed?

  • Disable lenient parsing for cached SimpleDateFormat instances.
  • Build java.time formatters with strict resolver semantics, normalizing unquoted y to u for patterns without an explicit era so yyyy remains valid without conflicting with proleptic years.
  • Add DateUtils and converter tests for invalid month-end/leap-day values, valid controls, negative and zero years, quoted literals, and explicit eras.

Verification:

JDK 21: DateUtilsTest, DateStringConverterTest, LocalDateStringConverterTest,
OffsetDateTimeConverterTest, YearStringConverterTest, CharacterAndYearFieldRoundTripTest
Tests run: 127, Failures: 0, Errors: 0, Skipped: 0
spotless:check: passed

Checklist

  • I have read the Contributor Guide.
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Signed-off-by: liuhy <liuhongyu@apache.org>
@bengbengbalabalabeng

Copy link
Copy Markdown
Contributor

Thanks for the contribution. Please resolve the merge conflicts and update the PR when you have a chance.

@bengbengbalabalabeng

Copy link
Copy Markdown
Contributor

Thanks for the contribution. Please resolve the merge conflicts and update the PR when you have a chance.

@Aias00 :)

@Aias00

Aias00 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the contribution. Please resolve the merge conflicts and update the PR when you have a chance.

done 😊

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Default date converters silently normalize invalid calendar dates

2 participants