users@jersey.java.net

Re: [Jersey] Parsing unix timestamp in JSON

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Fri, 29 Jan 2010 17:25:48 -0800

On Thu, Jan 28, 2010 at 10:08 AM, Chris Carrier <ctcarrier_at_gmail.com> wrote:
> When I just echo back the value after marshalling/unmarshalling it will turn
> a Unix timestamp from yesterday to:
>
> {"wrapped":"95508544-06-28T19:08:16.768-07:00"}

As far as I know, Unix timestamp (one with seconds, not milliseconds)
is not a default way to express time anywhere on Java platform. So I
am not really surprised that that would not work -- it's just an
unqualified number without context, after all (beyond hope that it
becomes Date or Calendar).
Worse, what I would consider standard is Java
System.currentTimeMillis(), which is milliseconds since epoch (i.e.
unix-timestamp * 1000). As such, unix timestamps would be valid but
incorrect Java timestamps.

Adding support for Unix timestamps may well make sense; and above
timestamp is bogus of course, no matter how it is sliced (i.e. seems
like a bug -- should be something around february 1970 or so, even if
value was 1/1000 of expected).

-+ Tatu +-