This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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");
  }
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]