pin locale when parsing dates in IsDateTimePlaceholderHandler - #335
Merged
Conversation
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>
Contributor
Author
|
good idea. pushed a commit that:
added a test covering the explicit locale too. |
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. |
Contributor
Author
|
sure, fine with me. good to have the empty second argument pinned down explicitly, go ahead and add it. |
Member
|
Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Locale-dependent date parsing in IsDateTimePlaceholderHandler
The explicit-pattern and ISO
SimpleDateFormatinstances are built without a locale, so the untrusted value is parsed against the JVM default locale:24 June 2023matchesdd MMMM yyyyon an English JVM but is rejected on a German or French one. Pinned both toLocale.USso the fixed formats parse the same everywhere; the locale-aware short-format fallbacks documented as "current locale" stay as is.