Name: boT120536 Date: 02/08/2001
java version "1.2.2"
Classic VM (build JDK-1.2.2_006, native threads, symcjit)
The toString method for java.sql.Date and java.sql.Timestamp does not print the
year field correct for years below 1000. It should left pad the year with
zeroes if the year does not fill all 4 places.
The example ...
class test {
public static void main (String args[]) {
java.sql.Date d;
d = java.sql.Date.valueOf("1-01-01");
System.out.println(d);
d = java.sql.Date.valueOf("12-01-01");
System.out.println(d);
d = java.sql.Date.valueOf("123-01-01");
System.out.println(d);
d = java.sql.Date.valueOf("999-01-01");
System.out.println(d);
java.sql.Timestamp ts;
ts = java.sql.Timestamp.valueOf("1-01-01 00:00:00");
System.out.println(ts);
ts = java.sql.Timestamp.valueOf("12-01-01 00:00:00");
System.out.println(ts);
ts = java.sql.Timestamp.valueOf("123-01-01 0:0:0");
System.out.println(ts);
ts = java.sql.Timestamp.valueOf("999-01-01 0:0:0");
System.out.println(ts);
}
}
outputs:
1-01-01
12-01-01
123-01-01
999-01-01
1-01-01 00:00:00.0
12-01-01 00:00:00.0
123-01-01 00:00:00.0
999-01-01 00:00:00.0
the correct output should be:
0001-01-01
0012-01-01
0123-01-01
0999-01-01
0001-01-01 00:00:00.0
0012-01-01 00:00:00.0
0123-01-01 00:00:00.0
0999-01-01 00:00:00.0
(Review ID: 116577)
======================================================================