This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Leap year bug in java.util.GregorianCalendar
- From: H. Väisänen <hvaisane at joyx dot joensuu dot fi>
- To: java-patches mailing list <java-patches at gcc dot gnu dot org>
- Date: Fri, 1 Aug 2003 15:01:38 +0300 (EET DST)
- Subject: Leap year bug in java.util.GregorianCalendar
The following program prints
1972-03-01
It should print
1972-02-29
It seems that in leap years all dates after 28 February are wrong.
No patch yet, and this is a good time to ask if this list is a proper
place to send bug reports without patches?
> gcc --version
gcc (GCC) 3.3
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
////////// The program
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.Calendar;
// gcj -Wall --main=LeapYearBug LeapYearBug.java -o bug
class LeapYearBug {
public static void main (String[] args)
{
DateFormat f = new SimpleDateFormat ("yyyy-MM-dd");
Calendar g = new GregorianCalendar (1972, 1, 29, 0, 0, 0);
System.out.println (f.format(g.getTime()) + "\n");
}
}