[kaffe] Bug in Kaffe 1.0.7

Ito Kazumitsu ito.kazumitsu at hitachi-cable.co.jp
Sun Jul 27 21:35:03 PDT 2003


In message "Re: [kaffe] Bug in Kaffe 1.0.7"
    on 03/07/28, Ito Kazumitsu <ito.kazumitsu at hitachi-cable.co.jp> writes:

> The attached program prints week-related values for the dates
> from Jan 1 2000 to Dec 31 2003.  Both GNU Classpath and Sun's
> JDK give identical results for the following months:
> 
>    Oct 2000, Apr 2001, Jul 2001, Sep 2002, Dec 2002, Jun 2003

These months are special in that the first day of the month is Sunday.

The attached patch makes GNU classpath's java.util.Calendar behave
almost similarly to Sun's JDK except that the former returns 53 or
54 as the last week of the year but the latter returns 1.   I think
that returning 1 as the last week of the year may be a bug of Sun's
JDK.

I will submit this patch to the GNU Classpath mailing list.

--- java/util/GregorianCalendar.java.orig	Sun Mar 24 01:10:15 2002
+++ java/util/GregorianCalendar.java	Mon Jul 28 11:53:16 2003
@@ -599,7 +599,7 @@
     // which day of the week are we (0..6), relative to getFirstDayOfWeek
     int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7;
 
-    fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 6) / 7;
+    fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7;
 
     int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7;
 




More information about the kaffe mailing list