-
Bug
-
Resolution: Fixed
-
P3
-
6
-
b48
-
generic
-
generic
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
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
- relates to
-
JDK-6314387 JCK6.0: api/java_util/Date/index.html#misc fails, mustang
-
- Closed
-