I am new to JAX-RS and I want to serve my list of items as JSON. My entity model is something like this:
public class Entity {
private String name;
private Date date;
private Float number;
}
This is how I am invoking the service:
@Path("/entities")
public class EntitiesController {
@GET
@Produces({"application/json"})
public List<Entity> getEntities() {
return EntityDAO.entitiesList();
}
}
However, the date is not formatted but is displayed as a long.
This answer shows how to format a date using a JsonSerializer
. If I extend JsonSerializer
, then where do I put that subclass in my project?