Skip to content

Pass configured locale to SimpleDateFormat in DateTimeConverter#421

Merged
garydgregory merged 2 commits into
apache:masterfrom
rootvector2:datetimeconverter-pattern-locale
Jul 18, 2026
Merged

Pass configured locale to SimpleDateFormat in DateTimeConverter#421
garydgregory merged 2 commits into
apache:masterfrom
rootvector2:datetimeconverter-pattern-locale

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

getFormat(String) builds the pattern SimpleDateFormat with the jvm default locale and ignores the converter's configured locale, so a converter given both setLocale and a pattern parses and formats month and day names in the default locale instead of the configured one; pass locale when it is set, matching DateLocaleConverter and StringLocaleConverter. found auditing locale handling across the date converters.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute?
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rootvector2 Please see my comment.

/**
* Test that a configured Locale is honored when a pattern is also set.
*/
@Test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use JUnit Pioneer to set a temporary Locale.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, switched the test to Pioneer's @DefaultLocale and dropped the manual save/restore. Added junit-pioneer as a test dependency since it wasn't in the pom yet (version comes from commons-parent). All 9 subclass runs still pass.

@garydgregory garydgregory changed the title pass configured locale to SimpleDateFormat in DateTimeConverter Pass configured locale to SimpleDateFormat in DateTimeConverter Jul 18, 2026
@garydgregory
garydgregory merged commit cdfcb33 into apache:master Jul 18, 2026
9 checks passed
@garydgregory

Copy link
Copy Markdown
Member

TY @rootvector2 Merged 🚀 Please port to 1.x if appropriate.

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.

2 participants