users@jersey.java.net

Re: [Jersey] Bug in Jersey's header parser?

From: Julian Reschke <julian.reschke_at_gmx.de>
Date: Mon, 03 Nov 2008 15:30:19 +0100

Paul Sandoz wrote:
> ...
> Jersey defers to a SimpleDateFormat instance for RFC 1123:
>
> SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy
> HH:mm:ss zzz", Locale.US);
> TimeZone tz = TimeZone.getTimeZone("GMT");
> sdf.setTimeZone(tz);
>
> GregorianCalendar d = new GregorianCalendar(2003,
> Calendar.FEBRUARY, 1);
>
> System.out.println("toString: " + d.getTime().toString());
> System.out.println(" format: " + sdf.format(d.getTime()));
>
> It looks like the setting of the time zone to GMT causes the date to be
> formated one day earlier. From the HTTP spec the time zone must be GMT
> [1]. Is this a bug in the date formatting code?
> ...

Hmm, is this a trick question? It's just one hour earlier, right?

Doesn't the answer just depend on the time difference between GMT, and
the VM's default locale (used by GregorianCalendar)?

BR, Julian