[kaffe] Bug report: java.text.SimpleDateFormat#parse

Ito Kazumitsu ito.kazumitsu at hidec.co.jp
Thu Jan 27 19:02:54 PST 2005


Hi,

In message "Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse"
    on 05/01/27, Dalibor Topic <robilad at kaffe.org> writes:


> Thanks Ito, I've applied your patch, as Andrew applied it to Classpath. 
> The regression test still fails for me, unfortunately.

This failure occurs with a time zone that has DST.

$ kaffe -Duser.timezone=JST DateFormatTest
Same time zone
Different time zone
$ kaffe -Duser.timezone=PST DateFormatTest
Same time zone
Different time zone
Dates don't match? Thu Oct 28 06:00:27 America/Los_Angeles 2004 != Thu Oct 28 05:00:27 America/Los_Angeles 2004

And it can be explained as follows:

JST (Zone offset = 9, DST offset = 0)

 java.text.SimpleDateFormat#parse     java.util.GregorianCalendar#computeTime 
   Parsed         Zone    DST         Zone        DST        Result in GMT/JST
   string         offset  offset      offset      offset
   13:00GMT+00:00 00:00   -           00:00*[1]   00:00*[2]  13:00 / 22:00

     [1] rawOffset = fields[ZONE_OFFSET] because isSet[ZONE_OFFSET]
     [2] dstOffset = 0 (DST offset of JST) because !isSet[DST_OFFSET]

PST (Zone offset = -8, DST offset = 1)

 java.text.SimpleDateFormat#parse     java.util.GregorianCalendar#computeTime 
   Parsed         Zone    DST         Zone        DST        Result in GMT/PDT
   string         offset  offset      offset      offset
   13:00GMT+00:00 00:00   -           00:00*[1]   01:00*[2]  12:00 / 05:00

     [1] rawOffset = fields[ZONE_OFFSET] because isSet[ZONE_OFFSET]
     [2] dstOffset = 1 (DST offset of PST) because !isSet[DST_OFFSET]

I should have added

  calendar.set (Calendar.DST_OFFSET, 0);

to the part where "GMT+xx:yy" is being parsed, not only just swapping
Calendar.DST_OFFSET and Calendar.ZONE_OFFSET.

By the way,

Dates don't match? Thu Oct 28 06:00:27 America/Los_Angeles 2004 != Thu Oct 28 05:00:27 America/Los_Angeles 2004
       ^^^^^^^^^^^^^^^^^^^

why "America/Los_Angeles" appears instead of "PDT" is explained in
    http://www.kaffe.org/pipermail/kaffe/2005-January/101286.html
    http://lists.gnu.org/archive/html/classpath/2005-01/msg00200.html





More information about the kaffe mailing list