0

I have a little problem with a service. When I receive a list of json the date is null, I think that is because json haven't date type. Is there a way to solve it and receive the real date and not null?

Im going to post some important code, thank you very much.

ServiceController

@RequestMapping(value="evento9", method=RequestMethod.GET, produces = "application/json")
    public ResponseEntity<?> evento9(@RequestParam(value="localizacion", required=true) String localizacion){
        ListaEventos listaComodin = new ListaEventos();
    listaComodin.setListaEvento(eventoDAO.findBySalaEvento(localizacion));
    return  new ResponseEntity<>(listaComodin,HttpStatus.OK);
}

Controller

    Client client = ClientBuilder.newClient();
            WebTarget webResource = client.target("http://localhost:8086").path("evento9")
                    .queryParam("localizacion", localizacion);
            ListaEventos eventoComodin =  webResource.request().accept("application/json").get(ListaEventos.class);
            request.setAttribute("eventos", eventoComodin.getListaEvento());
            request.getServletContext().getRequestDispatcher("/busqueda.jsp").forward(request,response);

Get y Set

@JsonDeserialize(using = CustomJsonDateDeserializer.class)
    public Date getFechaEvento() {
        return this.fechaEvento;
    }

    @JsonDeserialize(using = CustomJsonDateDeserializer.class)
    public void setFechaEvento(Date fechaEvento) {
        this.fechaEvento = fechaEvento;
    }
  • Possible duplicate of [How to get a Date from a JSON object](https://stackoverflow.com/questions/15761101/how-to-get-a-date-from-a-json-object) – vinS Dec 14 '17 at 03:41
  • I have tried it, but doesn't work – Stefan Daniel Dec 14 '17 at 03:45
  • Provide a working [mcve] with input and output. What json data are you trying to parse? What is your CustomJsonDateDeserializer implementation? Why have you marked a getter with @JsonDeserialize rather than @JsonSerialize? – Erwin Bolwidt Dec 14 '17 at 03:48

0 Answers0