0

In my spring boot application, there is a java object with date object. while printing the date from java code , it shows correct date and time.

But once I call the API which returns list of object , it returns wrong date

Here is the result I'm getting from java code when printing the date

Fri Feb 16 16:33:46 IST 2018

And the result I'm getting from API is

{
    "deviceId": 1,
    "datapointId": 27,
    "updatedTime": "2018-02-16T11:03:46",
    "avg": 0.5,
    "max": 0.5,
    "min": 0.5,
    "datapointTemplateId": 5633
}

"updatedTime" variable I have declared like this in the class

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
private Date updatedTime;

Is it serializer's issue? please help me

Thanks.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
Sanooj M
  • 45
  • 8

1 Answers1

1

The time in the JSON is UTC.

IST is 5:30 ahead of UTC (i.e. UTC+05:30), and this is exactly the offset between the two values.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
  • How can I convert the UTC date to local time from javascript? or can I avoid this automatic UTC conversion from server side itself? – Sanooj M Feb 23 '18 at 07:49
  • That's a different question. I've marked this as a duplicate of another question dealing with that topic. – Jim Garrison Feb 23 '18 at 07:51