Why not add an extra field which hold value of timezone?
发件人: Ian Anderson [mailto:insanes...@gmail.com]
发送时间: 2013年10月8日 2:42
收件人: resteasy-users@lists.sourceforge.net
主题: [Resteasy-users] Changing Default JSON Time Format with RESTEasy 3.x
I am using RESTEasy to implement a REST Service using JSON serialization.
Currently, Dates are getting serialized to milliseconds since 1970. To
improve compatibility, I would like to get my dates into one of two formats;
milliseconds + timezone offset or ISO 8061.
It seems that RESTEasy used to use Jettison for JSON serialization, but from
what I've been reading they've switch to Jackson ... all of this has made
googling for help pretty hit or miss.
>From what I can tell, I need to implement a ContextResolver<ObjectMapper>
along the lines of:
public class JacksonConfig impelments ContextResolver<ObjectMapper>
{
private final OBjectMapper objectMapper;
public JacksonConfig() throws Exception
{
objectMapper = new ObjectMapper.configure(
SerializationFeature.WRITE_DATE_AS_TIMESTAMPS, false);
}
@Override
public ObjectMapper getContext(Class<?> arg0)
{
return objectMapper;
}
}
The thing I haven't been able to find, is what do I do with this? Where do
I put it?
So the larger questions are, am I heading in the right direction and are my
assumptions correct?
Thanks!
--
Ian
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users