Hello all, I have discovered a bug (?) in jdk 1.1.7-v1a-glibc I am running a RedHat 5.2 i386 Linux with 2.2.5 kernel on a K6II-350 MHz/64 Mb RAM I am setting a new SimpleDateFormat with "yyyy-MM-dd" parsing format and I'm trying to parse and use some dates. Curiously, the ONLY date that doesn't work corectly is 1999-04-30 (ie April 30 in 1999). Any (29)30(31) of other months are working just fine! I am sending you also a small program to check and proove the error. The output of the program is : Parsing and testing the date of 1999 April 29 The parsed day is Thu Apr 29 00:00:00 GMT+02:00 1999 The date formatted as yyyy-MM-dd is 1999-04-29 Parsing and testing the date of 1999 April 30 The parsed day is Thu Apr 29 23:00:00 GMT+02:00 1999 The date formatted as yyyy-MM-dd is 1999-04-29 The above error doesn't exist when running the jdk 1.2 pre-release-v1 on the same system !!! [root@teo eforie]# java -version java version "1.2" Classic VM (build Linux_JDK_1.2_pre-release-v1, native threads, sunwjit) [root@teo eforie]# java april30 Parsing and testing the date of 1999 April 29 The parsed day is Thu Apr 29 00:00:00 GMT+03:00 1999 The date formatted as yyyy-MM-dd is 1999-04-29 Parsing and testing the date of 1999 April 30 The parsed day is Fri Apr 30 00:00:00 GMT+03:00 1999 The date formatted as yyyy-MM-dd is 1999-04-30 Please note the differences (GMT+02) <-> (GMT+03) between them. The program has been tested on the same machine (but different users teo & root) Here comes the test program! //program april30.java //-------------------- import java.text.*; import java.util.*; public class april30 { private Date thedate; private SimpleDateFormat sdf; public april30(String s) { sdf = new SimpleDateFormat("yyyy-MM-dd"); sdf.setLenient(false); try { thedate = sdf.parse(s); } catch (ParseException pe) { System.out.println("An exception occured trying to parse string "+s); } } public String toISO() { return sdf.format(thedate); } public String toString() { return thedate.toString(); } public static void main(String[] argv) { System.out.println("Parsing and testing the date of 1999 April 29"); april30 a1 = new april30("1999-4-29"); System.out.println("The parsed day is "+a1.toString()); System.out.println("The date formatted as yyyy-MM-dd is "+a1.toISO()); System.out.println(""); System.out.println("Parsing and testing the date of 1999 April 30"); april30 a2 = new april30("1999-4-30"); System.out.println("The parsed day is "+a2.toString()); System.out.println("The date formatted as yyyy-MM-dd is "+a2.toISO()); System.exit(0); } } //------------------------------ I will REALLY need jdk 1.1.7 to work corectly because some of my customers are already using java applications with this bug :-( And we have only 8 days left ... Best regards, -- Constantin Teodorescu FLEX Consulting Braila, ROMANIA
import java.text.*; import java.util.*; public class april30 { private Date thedate; private SimpleDateFormat sdf; public april30(String s) { sdf = new SimpleDateFormat("yyyy-MM-dd"); sdf.setLenient(false); try { thedate = sdf.parse(s); } catch (ParseException pe) { System.out.println("An exception occured trying to parse string "+s); } } public String toISO() { return sdf.format(thedate); } public String toString() { return thedate.toString(); } public static void main(String[] argv) { System.out.println("Parsing and testing the date of 1999 April 29"); april30 a1 = new april30("1999-4-29"); System.out.println("The parsed day is "+a1.toString()); System.out.println("The date formatted as yyyy-MM-dd is "+a1.toISO()); System.out.println(""); System.out.println("Parsing and testing the date of 1999 April 30"); april30 a2 = new april30("1999-4-30"); System.out.println("The parsed day is "+a2.toString()); System.out.println("The date formatted as yyyy-MM-dd is "+a2.toISO()); System.exit(0); } }