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

Add @JsonFormat.lenient to allow configuring lenience of date/time deserializers #105

Closed
chrisbloe opened this issue Nov 3, 2016 · 4 comments
Milestone

Comments

@chrisbloe
Copy link

When I specify a date in the form:
@JsonFormat(pattern = "yyyy-MM-dd") Date endDate;
I would like to set the leniency to false.

Currently, a value of 2016-225-35 is allowed, but I would like to make this invalid.

e.g.
@JsonFormat(pattern = "yyyy-MM-dd", lenient = false) Date endDate;

@cowtowncoder
Copy link
Member

Hmmh. This is tricky... leniency is such a java.util.Date (or, related date format) specific thing that it doesn't necessarily fit well with general-purpose annotations. But maybe it'd be possible to add some sort of extension mechanism that specific datatype (de)serializers could use.

@chrisbloe
Copy link
Author

Thanks for the quick reply :)

I thought this too, but there is already a timezone parameter, which is also Date specific? It's a shame there's no character that can be used in the pattern string that denotes leniency.

@cowtowncoder
Copy link
Member

True, timezone is indeed rather date/time specific; although unlike leniency covers multiple date/time libs.

Although come to think of that, general concept of leniency might actually be relevant for other types as well. So perhaps this is something that should be added for 2.9 (needs to be there since it's an API change; plus annotation packages never change in patch versions).

@cowtowncoder cowtowncoder changed the title @JsonFormat formatted date set leniency Add @JsonFormat.lenient to allow configuring lenience of date/time deserializers Nov 16, 2016
@cowtowncoder cowtowncoder added this to the 2.9 milestone Nov 16, 2016
@cowtowncoder
Copy link
Member

Added annotation; need to add issue for databind to actually make use of it.

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