I am trying to pass a date to the JAX-RS service. Checking for other issues, such as: Date format Mapping to JSON Jackson
The answers and documentation show that there is an annotation for Jackson that should allow date formatting.
public class SolutionFilter {
@MatrixParam("toDate")
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd", timezone="CET")
private Date toDate;
public void setToDate(Date toDate) {
this.toDate = toDate;
}
}
After calling the Rest-Service, I get ParseException:
Caused by: java.text.ParseException: Unparseable date: "2016-01-01"
at java.text.DateFormat.parse(DateFormat.java:366)
at org.glassfish.jersey.message.internal.HttpDateFormat.readDate(HttpDateFormat.java:137)
at org.glassfish.jersey.server.internal.inject.ParamConverters$DateProvider$1.fromString(ParamConverters.java:259)
The annotation seems to be ignored. When debugging a parsing method, the template has the value EEE, dd MMM yyyy HH:mm:ss zzzand EEE MMM d HH:mm:ss yyyy.
I am using Spring 4.2.1, Jersey 2.22, which bundles jackson 2.5.4.
How can I get dates processed with the correct template?
: , JSON . , , JAX-RS.