This repository has been archived by the owner on Nov 7, 2019. It is now read-only.
Handle JSON serialized Dates from JavaScript in LocalDateDeserializer #56
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.
I've been at this before (#28), however, during the review phase of the PR I accidentally borked my own use-case. Unfortunately I only found out after we switched from our internally patched version to the current 2.7 release.
It's now possible to parse a date and time ("2016-01-18T15:41:32.232") as LocalDate. However, what I needed was to be able to parse this, coming from JavaScript:
(notice the trailing Z, which is currently not accepted)
JavaScript generates an ISO instant string when serialising a JavaScript Date [1]. It seems I am not the only one running into this issue [2]. I think it would be great to revise my original PR to allow for this. That way, it works for many people doing Java/JS interop without having to override the pattern on each usage of a LocalDate field. The check for custom formatter (https://github.com/FasterXML/jackson-datatype-jsr310/issues/37) is obviously still in place. I also made the check for the presence of the time component a bit more robust.
Thanks for considering this PR. My CLA is already in place, so that should not be an issue.
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON & https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
[2] http://stackoverflow.com/questions/26233882/javascript-date-to-java-time-localdate & http://stackoverflow.com/questions/5591967/how-to-deserialize-js-date-using-jackson