[kaffe] Bug in Kaffe 1.0.7

Ito Kazumitsu ito.kazumitsu at hitachi-cable.co.jp
Sun Jul 27 18:49:02 PDT 2003


In message "Re: [kaffe] Bug in Kaffe 1.0.7"
    on 03/07/27, Ito Kazumitsu <kaz at maczuka.gcd.org> writes:

> Today (it is Sun Jul 27 07:33:35 JST 2003), both kaffe and Sun's JDK
> gave the same results.

Having tested various cases, I have got an idea that we should import
GNU Classpath's java.util.Calendar and its relatives.

GNU Classpath's java.util.Calendar also gives results different 
from those of Sun's,  but it seems by far the better than kaffe's.

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

On the other hand, kaffe's java.util.Calendar produces very
strange results:  adding one day to Jan 31 makes Jan 32 and
so on and Feburary never comes.

I am afraid correcting kaffe's java.util.Calendar and
java.util.GregorianCalendar is very hard and fruitless.

It was easy for me to import GNU Classpath's java.util.Calendar and
its relatives to kaffe.  I just copied java/util/Calendar.java,
java/util/GregorianCalendar.java and gnu/java/locale/Calendar*

Attaced program:

import java.util.*;
public class CalendarTest2 {
  public static void main(String[] args) {
    Calendar c = Calendar.getInstance();
    c.set(2000,0,1);
    for (;c.get(Calendar.YEAR) < 2004; c.add(Calendar.DATE, 1)) {
      System.out.print(c.get(Calendar.YEAR) + "-" +
                       (c.get(Calendar.MONTH) + 1) + "-" +
                       c.get(Calendar.DAY_OF_MONTH) + ",");
      System.out.print(c.get(Calendar.DAY_OF_WEEK) + ",");
      System.out.print(c.get(Calendar.DAY_OF_YEAR) + ",");
      System.out.print(c.get(Calendar.WEEK_OF_YEAR) + ",");
      System.out.print(c.get(Calendar.WEEK_OF_MONTH) + ",");
      System.out.print(c.get(Calendar.DAY_OF_WEEK_IN_MONTH) + ",");
      System.out.println();
    }
  }
}




More information about the kaffe mailing list