JDK-6274757 : (date) Date getTime and toString interaction for some time values
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-05-23
  • Updated: 2010-07-29
  • Resolved: 2005-08-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b48Fixed
Related Reports
Relates :  
Description
The following test shows two problems.

One, the date of the Gregorian cutover changed between JDK 1.4 and later JDKs.

Two, creating a Date from Calendar.getTime(), calling toString on it, then calling getTime on the Date, returns a different time than the Date originally started with.

public class GregoTest {
     public static void main(String args[]) {
         System.out.println("Java:" +  System.getProperty("java.version"));
         java.util.TimeZone jdkGMT = java.util.TimeZone.getTimeZone("GMT");
//        java.util.TimeZone.setDefault(jdkGMT);
         java.util.Calendar jdkCal = java.util.Calendar.getInstance(jdkGMT);
         jdkCal.clear();
         jdkCal.set(1582, java.util.Calendar.OCTOBER, 15);
         System.out.println("JDK time: " + jdkCal.getTime().getTime() );
         System.out.println("JDK time (str): " + jdkCal.getTime() );
         System.out.println("Day of month: " + 
             jdkCal.get(java.util.Calendar.DAY_OF_MONTH));
         Date co = jdkCal.getTime();
         System.out.println("Change over (Oct 15 1582) = " + co + " (" +
             co.getTime() + ")");
         long a = jdkCal.getTime().getTime();
         Date c = jdkCal.getTime();
         c.toString();
         long b = c.getTime();

         if(a!=b) {
             System.out.println("ERR: " + a + " != " + b);
         } else {
             System.out.println(a + " = " + b);
         }
     }
}

###@###.### 2005-05-23 20:39:49 GMT

Comments
EVALUATION In java.util.Date, the calendar system, Gregorian or Julian, must be determined based on local time, not UTC time.
02-08-2005