Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse
Dalibor Topic wrote: Ito Kazumitsu wrote: In message Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse on 05/01/29, Dalibor Topic [EMAIL PROTECTED] writes: : And even more thanks for your patch fixing the problem :) I've merged it : in from GNU Classpath, and now all tests pass again for me. But sadly enough, the recent change to java.util.GregorianCalendar, which does not honor zone offset and DST offset set before computeTime(), has made these chandes to java.text.SimpleDateFormat#parse ineffective. Yeah :( I've pinged Sven about it, and he's been hacking on a patch, as he told me today on IRC. He's aware of the issue, and I hope it will be fixed soon. I've checked Sven's fix in now. cheers, dalibor topic ___ kaffe mailing list kaffe@kaffe.org http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse
In message Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse on 05/01/29, Dalibor Topic [EMAIL PROTECTED] writes: : And even more thanks for your patch fixing the problem :) I've merged it : in from GNU Classpath, and now all tests pass again for me. But sadly enough, the recent change to java.util.GregorianCalendar, which does not honor zone offset and DST offset set before computeTime(), has made these chandes to java.text.SimpleDateFormat#parse ineffective. ___ kaffe mailing list kaffe@kaffe.org http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse
Ito Kazumitsu wrote: In message Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse on 05/01/29, Dalibor Topic [EMAIL PROTECTED] writes: : And even more thanks for your patch fixing the problem :) I've merged it : in from GNU Classpath, and now all tests pass again for me. But sadly enough, the recent change to java.util.GregorianCalendar, which does not honor zone offset and DST offset set before computeTime(), has made these chandes to java.text.SimpleDateFormat#parse ineffective. Yeah :( I've pinged Sven about it, and he's been hacking on a patch, as he told me today on IRC. He's aware of the issue, and I hope it will be fixed soon. cheers, dalibor topic ___ kaffe mailing list kaffe@kaffe.org http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse
Ito Kazumitsu wrote: Hi, In message Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse on 05/01/27, Dalibor Topic [EMAIL PROTECTED] writes: Thanks Ito, I've applied your patch, as Andrew applied it to Classpath. The regression test still fails for me, unfortunately. And it can be explained as follows: Konnichiwa Ito, Thanks a lot for your kind explanation! 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. And even more thanks for your patch fixing the problem :) I've merged it in from GNU Classpath, and now all tests pass again for me. 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 I've added a bug report for that to GNU Classpath bug database, so that it doesn't fall to the floor. cheers, dalibor topic ___ kaffe mailing list kaffe@kaffe.org http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse
Ito Kazumitsu wrote: In message [kaffe] Bug report: java.text.SimpleDateFormat#parse on 05/01/25, Ito Kazumitsu [EMAIL PROTECTED] writes: You might have found that test/regression/DateFormatTest.java fails recently. This is becuase of a bug in java.text.SimpleDateFormat#parse. And this is my patch. I am afraid whether or not this patch is applied, there may be cases where java.text.SimpleDateFormat#parse does not handle DST correctly, but this patch will work fine at least for those time zones which does not have DST. Thanks Ito, I've applied your patch, as Andrew applied it to Classpath. The regression test still fails for me, unfortunately. cheers, dalibor topic ___ kaffe mailing list kaffe@kaffe.org http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse
Hi, In message Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse on 05/01/27, Dalibor Topic [EMAIL PROTECTED] 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 ZoneDST ZoneDSTResult 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 ZoneDST ZoneDSTResult 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 ___ kaffe mailing list kaffe@kaffe.org http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
[kaffe] Bug report: java.text.SimpleDateFormat#parse
Hi, You might have found that test/regression/DateFormatTest.java fails recently. This is becuase of a bug in java.text.SimpleDateFormat#parse. The following program shows the bug. import java.text.SimpleDateFormat; public class Z { public static void main(String args[]) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat(yyMMddHHmmssSSSz); // System.out.println(sdf.parse(041028130027000GMT+00:00)); System.out.println(sdf.parse(041028130027000GMT+04:00)); } } This program prints (with -Duser.timezone=JST, JST=GMT+09:00): Thu Oct 28 09:00:27 JDT 2004 instead of the expected result: Thu Oct 28 18:00:27 JST 2004 The difference between JDT and JST has already been reported in http://www.kaffe.org/pipermail/kaffe/2005-January/101286.html And the difference between 09:00 and 18:00 is caused by the following bug in java/text/SimpleDateFormat.java 842 is_numeric = false; 843 calendar_field = Calendar.DST_OFFSET; 844 String[][] zoneStrings = formatData.getZoneStrings(); 845 int zoneCount = zoneStrings.length; 846 int index = pos.getIndex(); 847 boolean found_zone = false; 848 simpleOffset = computeOffset(dateStr.substring(index)); 849 if (simpleOffset != null) 850{ 851 found_zone = true; 852 saw_timezone = true; 853 offset = simpleOffset.intValue(); 854} At this point, GMT+04:00 has been parsed and offset gets 1440 milisoconds (4 hours). This offset should be set to the calendar's Calendar.ZONE_OFFSET but java/text/SimpleDateFormat.java fails to do so. Not only failing to set the offset, it does something unwanted. 941 else 942value = offset; 953 // Assign the value and move on. 954 calendar.set(calendar_field, value); This sets the offset value to the calendar's Calendar.DST_OFFSET. This make the wrong result. Parsed Zone offset DST offset GMT Result in JST Correct 13:00GMT+04:00 04:00- 09:00 18:00 Wrong13:00GMT+04:00 -04:00 00:00* 09:00 * 00:00 = 13:00 - 09:00 (default zone offset) - 04:00 (DST offset) ___ kaffe mailing list kaffe@kaffe.org http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
Re: [kaffe] Bug report: java.text.SimpleDateFormat#parse
In message [kaffe] Bug report: java.text.SimpleDateFormat#parse on 05/01/25, Ito Kazumitsu [EMAIL PROTECTED] writes: You might have found that test/regression/DateFormatTest.java fails recently. This is becuase of a bug in java.text.SimpleDateFormat#parse. And this is my patch. I am afraid whether or not this patch is applied, there may be cases where java.text.SimpleDateFormat#parse does not handle DST correctly, but this patch will work fine at least for those time zones which does not have DST. --- java/text/SimpleDateFormat.java.origTue Jan 25 14:50:18 2005 +++ java/text/SimpleDateFormat.java Tue Jan 25 16:35:03 2005 @@ -840,7 +840,7 @@ // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; - calendar_field = Calendar.DST_OFFSET; + calendar_field = Calendar.ZONE_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); @@ -868,8 +868,8 @@ found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); - calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); - offset = tz.getDSTSavings(); + calendar.set (Calendar.DST_OFFSET, tz.getDSTSavings()); + offset = tz.getRawOffset (); pos.setIndex(index + strings[k].length()); break; } ___ kaffe mailing list kaffe@kaffe.org http://kaffe.org/cgi-bin/mailman/listinfo/kaffe