I've seen similar questions answered on here, but none of the solutions are working for me. I have a javax.ws.rs REST API, and I'm trying to parse a java.util.Date, but can't seem to manage it. I believe the date parser is Jackson. How can I go about doing this? The error string talks about java.util.Calendar, but I'm not using that object, does that have something to do with it?
@POST
@Consumes(APPLICATION_JSON)
@Path("/tester")
@ApiOperation(value = "", response = String.class)
public String test(Tester tester) {
System.out.println(tester.getStr().toString());
throw new WebApplicationException(Response.Status.NOT_IMPLEMENTED);
}
My POJO class:
public class Tester {
@JsonSerialize(as=Date.class)
@JsonFormat(shape= JsonFormat.Shape.STRING, pattern="MM/dd/yyyy")
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
I get a 400 Bad Request with the output:
Exception Description: The object [12/11/1999],
of class [class java.lang.String],
from mapping [org.eclipse.persistence.oxm.mappings.XMLDirectMapping[str-->str/text()]] with descriptor [XMLDescriptor(canner.model.Tester --> [])],
could not be converted to [class java.util.Calendar]."