-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.4.2
-
x86
-
windows_xp
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
We have to convert date between java and ms excel. MS Excel uses 1900 year as a base one for its date fields. We tried to use Calendar object and saw strange things: If you create Calendar instance for 1900 year and try to add DATE_OF_YEAR, HOUR or other field to him, you will get wrong result. With other years 1901, 1899,etc it works fine. We can not change JDk version.
I use English version of WinXP sp2 with additional Russian input locale
. My TZ is GMT+2, DST is On.
Locale.getDefault() returns en_US.
If you could provide any additional tests I can run on my system I'd
send a logs to you.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
c.clear();
c.set(Calendar.YEAR, 1900);
System.out.println(c.getTime());
c.add(Calendar.HOUR, 24);
System.out.println(c.getTime());
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Mon Jan 01 00:00:00 EET 1900
Mon Jan 02 00:00:00 EET 1900
ACTUAL -
Mon Jan 01 00:00:00 EET 1900
Mon Jan 01 23:34:52 EET 1900
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Calendar;
/**
* @author ###@###.###
*/
public class TestDates {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
c.clear();
c.set(Calendar.YEAR, 1900);
System.out.println(c.getTime());
c.add(Calendar.HOUR, 24);
System.out.println(c.getTime());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
not to use Calendar , convert to other base year but not to 1900
Release Regression From : 1.4.2_07
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
###@###.### 2005-06-07 08:36:30 GMT
- duplicates
-
JDK-8168411 Adding 24 minutes to timestamp represented as Date
- Closed
-
JDK-8077673 GregorianCalendar: Julian dates before 1899-12-21 are wrong
- Closed
-
JDK-8174907 Calendar gives wrong time on 01.01.1900 for some african time zones
- Closed
-
JDK-8214243 Different/wrong historical timezone offsets applied in old vs. new time API
- Closed
- relates to
-
JDK-8061577 Milliseconds computed by Calendar and Instant differ before 1893-04-01
- Closed
-
JDK-8285844 TimeZone.getTimeZone(ZoneOffset) does not work for all ZoneOffsets and returns GMT unexpected
- Resolved