Name: jl125535 Date: 01/16/2002
FULL PRODUCT VERSION :
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.3.1_01a)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
java version "1.2.2"
Solaris VM (build Solaris_JDK_1.2.2_07, native threads, sunwjit)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]
ADDITIONAL OPERATING SYSTEMS :
Solaris 5.8
A DESCRIPTION OF THE PROBLEM :
The java.util.Date(long) constructor produces incorrect Date
values for negative numbers smaller than -111081607200000 so
that there exists a negative number for which the resulting
date is the same as the correct positive number.
For example, both Date(1010686408060) and
Date(-125313284792000 ) produce Thu Jan 10 12:13:28 CST 2002.
In 1.4 beta 3 and 1.3.1 on Solaris 8, the code produces a compiler error.
It appears that the Date(long) constructor has some restrictions
on the domain of the parameter. It would be helpful if the javadoc
(and the compiler) mentioned those restrictions.
The acceptable range for long integer types is at
"http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html#85587".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create a java.util.Date object using the (long)
constructor with a negative value smaller than -111081607200000.
2. Date object created is not correct (or a compiler error results).
EXPECTED VERSUS ACTUAL BEHAVIOR :
using -111081607200000
produces Sat Jan 01 00:00:00 CST 1551 which is correct
using -111081607200001
produces Fri Dec 31 23:59:59 CST 1552 which is incorrect
the Correct value should be sometime before 1551 rather than
after
In 1.4 beta 3 and 1.3.1 on Solaris 8, the code produces a compiler error.
% javac *.java
DateTest.java:6: integer number too large: -111081607200000
Date argDate1 = new Date(-111081607200000);
^
DateTest.java:7: integer number too large: -111081607200001
Date argDate2 = new Date(-111081607200001);
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.*;
public class test {
public static void main(String args[]) {
Date argDate1 = new Date(-111081607200000);
Date argDate2 = new Date(-111081607200001);
System.out.println("arg date1: " + argDate1);
System.out.println("arg date2: " + argDate2);
}
}
---------- END SOURCE ----------
(Review ID: 138158)
======================================================================