Convertir el tipo ZonedDateTime a Gson
Tengo un servicio de descanso que devuelve una lista de objetos de la matriz, y he implementado un cliente jersy restful para ejecutarlo, pero tengo problemas para convertir el tipo ZonedDateTime a json, así que recibo este error
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 231 path $[0].lastmodifieddate
¿Como puedo solucionar este problema?
columna lastmodifieddate en entidad
@Column(name = "lastmodifieddate")
private ZonedDateTime lastmodifieddate;
//getter and setter
servicio de descanso
@RequestMapping(value = "/getScoreFactor",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<Scorefactor> getScoreFactor() throws JSONException {
return scoreService.getScoreFactor();
}
cliente tranquilo inquieto
try {
Client client = Client.create();
WebResource webResource = client
.resource("http://localhost:8080/adap/api/getScoreFactor");
ClientResponse response = webResource.accept("application/json")
.get(ClientResponse.class);
String output = response.getEntity(String.class);
System.out.println("output--"+output);
Type listType = new TypeToken<List<Scorefactor>>() {}.getType();
List<Scorefactor> scorefactors = new Gson().fromJson(output,listType);
System.out.println(scorefactors);
} catch (Exception e) {
e.printStackTrace();
}