Update DateTimeUtils#parse to support date strings - #313
Merged
Merged
Conversation
Updated the DateTimeUtils class to allow evaluation of date strings without a timestamp, e.g., "1970-01-01". Although this is not generally used in SCIM, it broadens compatibility in certain cases, such as if a date is provided in a SCIM filter without a timestamp. Date strings will be given a timestamp marking the beginning of the day. This does incur a small performance penalty for identifying invalid date strings. However, this tradeoff is worthwhile to provide a slightly more useful parsing implementation. In general, most invocations are expected to provide a valid string, and that primary path is unaffected. Reviewer: dougbulkley Reviewer: vyhhuang JiraIssue: DS-51859
kqarryzada
commented
Aug 21, 2026
| return new Object[][] | ||
| { | ||
| new String[] { "1989-03-14T17:56:47+09:999" }, | ||
| new String[] { "1989-03-14T17:56:47+99:00" }, |
Collaborator
Author
There was a problem hiding this comment.
I removed these since timezones don't get the useful "Invalid value for..." message that matches the regex in the test above.
kqarryzada
commented
Aug 21, 2026
| // RFC 7643 states that "A date time... has no case sensitivity". | ||
| testcase("2079-10-18t08:53:50-08:00", 3464873630000L, zone(-8)), | ||
| testcase("2098-06-17T20:13:43z", 4053874423000L, UTC), | ||
| testcase("2098-06-17t20:13:43z", 4053874423000L, UTC), |
Collaborator
Author
There was a problem hiding this comment.
These were already supported, but now there is a dedicated regression test.
vyhhuang
approved these changes
Aug 21, 2026
vyhhuang
left a comment
Collaborator
There was a problem hiding this comment.
These changes look good to me.
dougbulkley
approved these changes
Aug 24, 2026
dougbulkley
left a comment
There was a problem hiding this comment.
Claude suggests these additions into the datesWithoutTimestamps data provider, I'll leave it up to you to implement or not:
// RFC 7643 states that "A date time... has no case sensitivity".
// This should also apply to the date-only fallback parsing path.
{ "1970-01-01z", 0L, UTC },
// Non-zero-minute offsets, to match the variety already covered
// for full timestamps in 'timestampTestCases'.
{ "1970-01-01+05:30", -19800000L, zone(5, 30) },
{ "1970-01-01-09:30", 34200000L, zone(-9, -30) },
// An explicit "+00:00" offset should be equivalent to "Z".
{ "1970-01-01+00:00", 0L, UTC },
Collaborator
Author
Thanks Doug. I don't anticipate a strong need to support these edge cases if we ever update the parser, so I'll forgo this for the time being. |
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.
Updated the DateTimeUtils class to allow evaluation of date strings without a timestamp, e.g., "1970-01-01". Although this is not generally used in SCIM, it broadens compatibility in certain cases, such as if a date is provided in a SCIM filter without a timestamp. Date strings will be given a timestamp marking the beginning of the day.
This does incur a small performance penalty for identifying invalid date strings. However, this tradeoff is worthwhile to provide a slightly more useful parsing implementation. In general, most invocations are expected to provide a valid string, and that primary path is unaffected.
Reviewer: dougbulkley
Reviewer: vyhhuang
JiraIssue: DS-51859