Topic
No replies
SystemAdmin
SystemAdmin
11979 Posts
ACCEPTED ANSWER

Pinned topic WSAD7 / Java 1.5 reporting the wrong time after Daylight changes.

‏2008-04-06T06:07:17Z |
First, if this is the wrong thread, please direct me the correct one :-)

I work in Tel Aviv, using WSAD7 IBM Java 1.5 and sometimes Sun Java 1.5 Since the DST change, Java reports the time as 'one hour ahead'. I get the following;

Locale.getDefault() --> iw_IL (CORRECT)
new GregorianCalendar().getTime() --> now + 1 hour (WRONG)
new GregorianCalendar().getTimeZone() --> Asia/Jerusalem (CORRECT)
new GregorianCalendar().useDaylightTime() --> true (CORRECT)
System.currentTimeMillis() --> now + 1 hour (WRONG)

I had the same problem in Sun Java 1.5. There is a 'registry fix', if one sets 'DisableAutoDaylightSet=1', Sun Java 1.5 reports ;

Locale.getDefault() --> iw_IL (CORRECT)
new GregorianCalendar().getTime() --> now! (CORRECT)
new GregorianCalendar().getTimeZone() --> GMT+2 (CORRECT, but not Asia/Jerusalem!?, I don't use this anyway).
new GregorianCalendar().useDaylightTime() --> false (WRONG, but our PCs are sync'd with a central server and we don't care if this is true or false).--> now + 1 hour (WRONG)
System.currentTimeMillis() --> now! (CORRECT)

This 'fix' does not work for IBM Java 1.5. The timezone database is correct as it has the correct start-finish times for DST here).

Is this a JVM bug? Is there a work-around (preferrably central - I don't want to change every Java app)?