Skip to content

Supported parsing date time text with valid zero zone offsets #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 15, 2017

Conversation

kevinjom
Copy link
Contributor

Refer to #18

* @since 2.9.0
*/
private static final String ISO8601_UTC_ZERO_OFFSET_SUFFIX_REGEX = "\\+00:?(00)?$";
private static final String ISO8601_UTC_ZERO_OFFSET_REGEX = "[^\\+]+" + ISO8601_UTC_ZERO_OFFSET_SUFFIX_REGEX;
Copy link
Member

Choose a reason for hiding this comment

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

This should be pre-compiled as Pattern for performance reasons.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, will fix

@@ -285,6 +288,20 @@ private ZoneId getZone(DeserializationContext context)
return (_valueClass == Instant.class) ? null : context.getTimeZone().toZoneId();
}

private String replaceZeroOffsetAsZIfNecessary(String text)
{
if (replaceZeroOffsetAsZ && endsWithZeroOffset(text)) {
Copy link
Member

Choose a reason for hiding this comment

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

This seems to evaluate regexp twice, first to match, then to replace: would it be possible to make that just one operation? Regexp evaluation has non-trivial cost, even considering that textual date handling itself is rather expensive operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment @cowtowncoder, I just checked the doc, your point makes perfect sense, I was wrong, I remember if no match found that would throw an exception. will fix

@cowtowncoder
Copy link
Member

Thank you for contributing this, yes, makes sense. The only suggestion I have is that since regexp handling has some overhead, it'd be good to do the usual optimization: pre-compile regexp String as Pattern (as they are immutable and can be shared, reused), and try to avoid matching and replacing as separate steps.

@cowtowncoder
Copy link
Member

One other thing: I'm happy to merge this (ideally with changes although I can probably make them myself too if need be), but unless I've asked before we need a filled Contributor License Agreement (CLA) before the first contribution (but just once, it's good for any other patches).
Document is at:

https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf

and usually it's easiest to print, fill & sign, scan, email to info at fasterxml dot com.
Once this occurs (apologies if I've asked for this before), I can merge the PR.

Thank you again for the contribution!

@kevinjom
Copy link
Contributor Author

@cowtowncoder I am really grateful for the comments and excited to contribute to this project, I will sign that CLA and send email later (well, before I fixed all the issues you pointed)

@kevinjom
Copy link
Contributor Author

@cowtowncoder comments fixed and CLA mail sent. Please have a look.

@cowtowncoder
Copy link
Member

@kevinjom Thank you!

@cowtowncoder cowtowncoder merged commit aa76baf into FasterXML:master Mar 15, 2017
@cowtowncoder cowtowncoder added this to the 2.9.0.pr2 milestone Mar 15, 2017
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