-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.3.0
-
x86
-
windows_98
Name: tb29552 Date: 01/10/2001
C:\try>java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
/*
* java.util.Date.getTime() returns a long, hence this entire
* expression should be widened and evaluated as long:
* "d1.getTime() + 1*365*24*60*60*1000"
* Reference section 4.2.2 "Integer Operations" of the JLS
* http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html#51035
*/
import java.util.Date;
class LongVersusInt {
public static void main(String[] args){
Date d1 = new Date(-2208960000000L);//Mon Jan 01 08:00:00 GMT 1900
Date d2 = new Date( d1.getTime() + 1*365*24*60*60*1000);
// After silently overflowing, javac reduces this
// to: new Date( d1.getTime() + 1471228928);
/*
* Addition of the "L" suffix forces the entire expression to be
* widened:
*/
Date d3 = new Date( d1.getTime() + 1*365*24*60*60*1000L);
// javac reduces to: new Date( d1.getTime() + 31536000000L);
System.out.println(d1);
System.out.println(d2);
System.out.println(d3);
}
}
(Review ID: 114615)
======================================================================
- relates to
-
JDK-4463003 java.math.BigInteger has incorrect static final
-
- Closed
-