Name: jl125535 Date: 05/02/2002 A DESCRIPTION OF THE PROBLEM : The javadoc for java.sql.Timestamp can be confusing. The class desciption states that "only integral seconds are stored in the java.util.Date component." However, the description of getTime() claims that the method "returns the number of milliseconds ... represented by this Timestamp object." Many people do not believe that milliseconds are "integral" seconds. As a result, some users believe that the code given below should return The values are NOT equal sv: 767676767676 sv2: 767676767000 instead of The values are equal sv: 767676767676 sv2: 767676767676 ---------- BEGIN SOURCE ---------- import java.sql.Timestamp; public class LongValueTest { public static void main(String[] args) { long sv = 767676767676L; Timestamp time = new Timestamp(sv); long sv2 = time.getTime(); if (sv == sv2) { System.out.println("The values are equal"); } else { System.out.println("The values are NOT equal"); } System.out.println("sv: "+sv); System.out.println("sv2: "+sv2); } } ---------- END SOURCE ---------- (Review ID: 145942) ====================================================================== JDK 1.3.x did not return the milliseconds portion of the time. In other words, the test case would result in The values are NOT equal sv: 767676767676 sv2: 767676767000 with JDK 1.3.1. (Review ID: 146854)
|