-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b37
-
sparc
-
solaris_2.6
-
Verified
Name: dsR10051 Date: 12/10/2003
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta-b30"
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : N/A
Problem description
===================
Method class java.util.TimeZone.setRawOffset(int) has negative static impact to
methods of class java.util.Date. Mimimized test demonstrates this bug.
Minimized test:
===============
------- test5.java -------
import java.util.*;
public class test5 {
public static void main (String[] args) {
long millis = Long.MAX_VALUE - Integer.MAX_VALUE / 2 + 1000;
Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
Date date = new Date();
date.setTime(millis);
int resultSeconds = date.getSeconds();
calendar.setTime(date);
int expectedSeconds = calendar.get(Calendar.SECOND);
if (expectedSeconds != resultSeconds) {
System.out.println("1");
System.out.println("date = " + date);
System.out.println("millis = " + millis);
System.out.println("expected seconds = " + expectedSeconds);
System.exit(1);
}
TimeZone value1 = TimeZone.getDefault();
value1.setRawOffset(Integer.MAX_VALUE / 2);
calendar = new GregorianCalendar(TimeZone.getDefault());
value1 = TimeZone.getDefault();
date = new Date();
date.setTime(millis);
resultSeconds = date.getSeconds();
calendar.setTime(date);
expectedSeconds = calendar.get(Calendar.SECOND);
if (expectedSeconds != resultSeconds) {
System.out.println("2");
System.out.println("date = " + date);
System.out.println("millis = " + millis);
System.out.println("result = " + resultSeconds);
System.out.println("expected seconds = " + expectedSeconds);
System.exit(1);
}
}
}
------- end-of-test5.java -------
Minimized test output:
======================
$ echo $TZ
Europe/Moscow
$ /set/java/jdk1.5.0/solaris/bin/java test5
2
date = Sat Dec 15 00:02:47 MSK 292269055
millis = 9223372035781034984
result = 56
expected seconds = 38
JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests
Additional comments:
====================
Test sets raw offset for default timezone. Then it creates Date object and
GregorianCalendar to check Date.getSeconds method.
Note: TimeZone.getDefault returns copy of default time zone, so setRawOffset(int)
should not have impact to another TimeZone instance.
Under jdk 1.4.2 mimimized test works correct.
======================================================================