I am having some troubles whit an endpoint that returns an object that contains a date (this date comes from a web service response).
So, right now these are the steps
- I read the response from the webservice, and i set it on the "TicketAcceso" object.
//example
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
System.out.println("Read from the xml response = "+dateLineXmlResponse);
//OUTPUT = "Read from the xml response = 2019-09-27T01:56:14.467-03:00"
Date expDate = new Date(dateFormat.parse(dateLineXmlResponse).getTime());
ticketAcceso.setFechaVencimiento(expDate);
Save the object (actually from a bigger class, "Session", that contains one "TicketAcceso"), this is working, the date is now saved in mysql.
Then i have a get endpoint that returns a TicketAcceso, the thing is:
. The Date is correct in the database (OK value, without timezone info). . If i get the date from the object just before returning from the endpoint, the value is ok (it uses the local timezone)
System.out.println("Getting the date from the object before returning =
"+ticketAccesoNuevo.getFechaVencimiento());
//OUTPUT = "Getting the date from the object before returning = Fri Sep 27 01:56:14 ART 2019"
//returns the TicketAcceso
BUT
The endpoint returns the date in UTC timezone
Actual MySQL value =
Endpoint return value =

Is there a way for returning the date in the local TimeZone? I've already added these lines:
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_example?
useLegacyDatetimeCode=false
spring.jpa.properties.hibernate.jdbc.time_zone=America/Argentina/Buenos_Aires</code>