Leap year bug in java.util.GregorianCalendar
H. Väisänen
hvaisane@joyx.joensuu.fi
Fri Aug 1 14:19:00 GMT 2003
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");
}
}
More information about the Java-patches
mailing list