Skip to content

pin locale when parsing dates in IsDateTimePlaceholderHandler - #335

Merged
bodewig merged 2 commits into
xmlunit:mainfrom
jmestwa-coder:isdatetime-locale
Jul 8, 2026
Merged

pin locale when parsing dates in IsDateTimePlaceholderHandler#335
bodewig merged 2 commits into
xmlunit:mainfrom
jmestwa-coder:isdatetime-locale

Conversation

@jmestwa-coder

Copy link
Copy Markdown
Contributor

Locale-dependent date parsing in IsDateTimePlaceholderHandler
The explicit-pattern and ISO SimpleDateFormat instances are built without a locale, so the untrusted value is parsed against the JVM default locale: 24 June 2023 matches dd MMMM yyyy on an English JVM but is rejected on a German or French one. Pinned both to Locale.US so the fixed formats parse the same everywhere; the locale-aware short-format fallbacks documented as "current locale" stay as is.

@bodewig

bodewig commented Jul 4, 2026

Copy link
Copy Markdown
Member

what do you think about adding an optional second parameter people could use to specify the locale explicitly (and documenting US as the default)?

- add optional second argument to select the parsing locale
- default to Locale.US when none is given
- document the new argument and add release notes entry

Signed-off-by: Syed Mohammed Nayyar <jmestwa@gmail.com>
@jmestwa-coder

Copy link
Copy Markdown
Contributor Author

good idea. pushed a commit that:

  • adds an optional second argument to pick the parsing locale (BCP 47 language tag, e.g. de or fr-FR)
  • keeps Locale.US as the default when it's omitted
  • documents that on evaluate and adds a release notes entry

added a test covering the explicit locale too.

@bodewig

bodewig commented Jul 5, 2026

Copy link
Copy Markdown
Member

while porting this to .NET I realized the special case of an empty second argument is not explicitly tested, I added 084d1a4 to a local clone. I'd add that if this is fine with you.

@jmestwa-coder

Copy link
Copy Markdown
Contributor Author

sure, fine with me. good to have the empty second argument pinned down explicitly, go ahead and add it.

@bodewig

bodewig commented Jul 8, 2026

Copy link
Copy Markdown
Member

Thank you

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