Google for it - lots of examples around
On 16/08/16 21:58, KARR, DAVID wrote:
-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]]
Sent: Tuesday, August 16, 2016 1:30 PM
To: [email protected]
Subject: Re: Same code has Date rendering in JSON with local timezone on
desktop, but "Z" on VM from desktop
Hi David
If you use CXF JSONProvider then JAXB will deal with reporting the value
of a given Date field, if Jackson - then Jackson does it.
If it is JAXB - consider trying a type adapter to control it
I'm using "org.apache.cxf.jaxrs.provider.json.JSONProvider", which I assume is the stock CXF JSON
provider, so I assume the JAXB comment is relevant. Can you be more specific about "trying a type
adapter"? I noticed the extremely brief mention of "@XmlJavaTypeAdapter annotations" in the
CXF JAX-RS doc, but I don't know what else to do with that.
On 16/08/16 18:00, KARR, DAVID wrote:
I'm not sure where the problem for this lies, but I'm having a
confusing issue with the out of the box JSON rendering of Date values,
with respect to timezones.
For instance, a datetime value I'm getting from the DB is "2016-08-16
00:24:07.495". This unfortunately doesn't have a timezone value, but it
can be assumed to be in the PST timezone. When I run my service on my
Windows laptop, which is in the PST timezone (-7:00), the Date field
that gets this value gets rendered in JSON as "2016-08-16T00:24:07.495-
07:00". This is good, as far as I can tell. This value is read my
javascript running in my browser and displays it properly according to
my local timezone (about 24 minutes after midnight early this morning).
When I run the same code on a Linux VM (which reports the same time
and timezone as the laptop) running off of the laptop, even though the
database query gets the same value back, the JSON coming from CXF
renders as "2016-08-16T00:24:07.495Z". This translates to my local
timezone in javascript as 7 hours before that time, being the middle of
the afternoon on the previous day, which is wrong.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/