Hi everyone,

The Trinidad DateTimeConverter has a problem when using JDK 6, because of changes in SimpleDateFormat. I have written a test case to replicate the converter's behavior.

Test case:
    DateFormat df = DateFormat.getDateTimeInstance (DateFormat.SHORT, 
DateFormat.LONG);
    Date d = new Date();
    // getFormattingTimeZone copied from trinidad-impl\DateTimeConverter.java, 
it clones the converter's timezone and gives it a
   //  customID (GMT +/- offset)./ This affects the display name, e.g. instead 
of 'PST' it will display 'GMT-08:00'
    TimeZone tz = getFormattingTimeZone (df.getTimeZone());
    df.setTimeZone (tz);
    System.out.println ("The date is " + d + ", DateFormat.format() returns " + 
df.format (d));

On JDK 1.5 this prints:
The date is Wed Jul 08 10:55:25 PDT 2009, DateFormat.format() returns 7/8/09 10:55:25 AM GMT-07:00

On JDK 6:
The date is Wed Jul 08 10:56:39 PDT 2009, DateFormat.format() returns 7/8/09 10:56:39 AM GMT-08:00

Notice that the offset in the second case is 8h. This is incorrect, the date (Jul 8 09) is in Pacific Daylight time (GMT-7), and if posted back, it would change the underlying data by +1h.

I can understand why getFormattingTimeZone was originally used: timezone is thus always displayed in GMT +/- x, which helps when calculating offsets on the client side. I would like to discuss the possible fixes for the JDK 6 case (details to follow in second email), any input is welcome.

I've filed a JIRA tracking this:
https://issues.apache.org/jira/browse/TRINIDAD-1512

Thanks,
Yee-Wah

Reply via email to