users@jersey.java.net

[Jersey] Re: Date serialization format

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Fri, 18 Nov 2011 15:39:40 -0800

On Fri, Nov 18, 2011 at 1:40 AM, Sadokhin, Vasiliy
<vasiliy_at_lionhearth.com> wrote:
> Hello
> Is there way to specify JSON response date format?
> The default template is "yyyy-MM-dd'T'HH:mm:ss.SSSZ". But I need another.
> I tried advices from that
> http://stackoverflow.com/questions/4428109/jersey-jackson-json-date-serialization-format-problem-how-to-change-the-form discussion,
> but it didn't help me to change date format. Is it possible?

Just configure ObjectMapper with the date format you want:

  objectMapper.setDateFormat(new SimpleDateFormat(...));

and that's it. Assuming you use POJO mapping.

-+ Tatu +-