Skip to content
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

Allow use of StdDateFormat.setLenient() #803

Closed
raj-ghodke opened this issue May 21, 2015 · 1 comment
Closed

Allow use of StdDateFormat.setLenient() #803

raj-ghodke opened this issue May 21, 2015 · 1 comment
Milestone

Comments

@raj-ghodke
Copy link

ObjectMapper uses the StdDateFormat for date serialization. Jackson date parsing is lenient by default, so 2015-01-32 gets parsed as 2015-02-01. Jackson’s StdDateParser is matching default behavior of DateParser.

StdDateParser wasn’t really designed for extension to just enable strict date parsing. If it were, we could just call objectMapper.setDateFormat(new StdDateFormat().setLenient(false)). But StdDateFomrat doesn't support setting lenient to false. And i.e. the reason date like 2015-01-32 gets parsed as 2015-02-01 ad Jackson date parsing is lenient by defualt.

Can StdDateFormat can be enhanced to support to non lenient date parsing?

@cowtowncoder
Copy link
Member

Was about to comment that setLenient() exists from the base class but then realized that while true, that will not have an effect on DateFormat instances that are actually used.

So: it should be possible to support non-leniency setting. I can not change setLenient to be chainable (non-covariant change is illegal I think), but it could be changed to pass setting to contained format instances.

@cowtowncoder cowtowncoder changed the title lenient date parsing in StdDateFormat. No support for non lenient date parsing. Can't call stdDateFomrat.setLenient(false) Allow use of StdDateFormat.setLenient() Dec 23, 2015
@cowtowncoder cowtowncoder added this to the 2.7.0-rc3 milestone Dec 23, 2015
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

No branches or pull requests

2 participants