In message "Re: Bug report: java.util.GregorianCalendar"
    on 03/08/28, Mark Wielaard <[EMAIL PROTECTED]> writes:

> Thanks. I finally looked into this.
> I created a simple Mauve test case for this (attached), but even with
> your patch it still gives a few failures.
> 
> FAIL: gnu.testlet.java.util.GregorianCalendar.first: 1-3-2000 (number 1)
> got 2 but expected 1
> FAIL: gnu.testlet.java.util.GregorianCalendar.first: 1-6-2000 (number 1)
> got 2 but expected 1
> FAIL: gnu.testlet.java.util.GregorianCalendar.first: 1-4-2004 (number 1)
> got 2 but expected 1
> FAIL: gnu.testlet.java.util.GregorianCalendar.first: 1-12-2004 (number 1)
> got 2 but expected 1
> 4 of 72 tests failed
> 
> Could you see if my test or GregorianCalendar is faulty?

Thank you for your attention.

First,  the number of month is 0-based.  So

>       for (int month = 1; month <= 12; month++)

should be

       for (int month = 0; month < 12; month++)

And I have found another bug shown by the attached program.
This bug seems to have something to do with leap yeas.
If this bug is fixed, my patch about the WEEK_OF_MONTH will
work.

$ cat TestGregorianCalendar.java
import java.util.*;
public class TestGregorianCalendar {
  public static void main(String[] args) {
    for (int year = 2000; year <= 2005; year++) {
      for (int month = 0; month < 12; month++) {
        GregorianCalendar cal = new GregorianCalendar(year, month, 1);
        if (cal.get(Calendar.DAY_OF_MONTH) != 1) {
          System.out.println (
            cal.get(Calendar.YEAR) + "-" +
            (cal.get(Calendar.MONTH) + 1) + "-" +
            cal.get(Calendar.DAY_OF_MONTH));
        }
      }
    }
  }
}
$ java  TestGregorianCalendar
2000-3-2
2000-4-2
2000-5-2
2000-6-2
2000-7-2
2000-8-2
2000-9-2
2000-10-2
2000-11-2
2000-12-2
2004-3-2
2004-4-2
2004-5-2
2004-6-2
2004-7-2
2004-8-2
2004-9-2
2004-10-2
2004-11-2
2004-12-2


_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to