Wrong Timezone on Windows XP PC

I have a very strange problem on a windows pc:

The local timezone on the pc is CET. But the timezone in java is GMT. To test this I wrote a very simple java program which only creates a new Date and print it to System.out:

System.out.println(new Date()) results in

Wed Jun 27 14:44:10 GMT 2007

but the expected result is

Wed Jun 27 16:44:25 CEST 2007

This problem seems not depend on the java version, because we tested it with 1.5.0_11 and 1.6.0_01

We are using JavaWebStart, so it is not allowed to change the timezone in the program. So the program uses the wrong timezone and I cannot change it.

This problem seems only to occur on this pc:

os.arch: x86

os.name: Windows XP

os.version: 5.1

Obviously java cannot lookup the right timezone from the operating system. So it seems to me that some settings in XP are the problem.

Did anybody here face the same problem? What did you do to solve it?

[982 byte] By [dirkeidena] at [2007-11-27 9:06:43]
# 1
The problem is usually solved by using DateFormat to format date strings...Although, of course, if the locale is set incorrectly... hm.
CeciNEstPasUnProgrammeura at 2007-7-12 21:42:31 > top of Java-index,Java Essentials,Java Programming...
# 2
What does this print out on the respective machine?System.out.println(TimeZone.getDefault());
quittea at 2007-7-12 21:42:31 > top of Java-index,Java Essentials,Java Programming...
# 3
Sounds like it's related to this problem: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5066671
quittea at 2007-7-12 21:42:31 > top of Java-index,Java Essentials,Java Programming...
# 4
TimeZone.getDefault().getDisplayName(): Greenwich Zeit(expected: Zentraleurop鋓sche Zeit)System.getProperty("user.timezone"): GMT(expected: Europe/Berlin)
dirkeidena at 2007-7-12 21:42:31 > top of Java-index,Java Essentials,Java Programming...
# 5
Have you already checked my last post? There seems to be a discrepancy between time zone identifiers between international and localized versions of Windows XP
quittea at 2007-7-12 21:42:31 > top of Java-index,Java Essentials,Java Programming...
# 6

I read your problem and I checked the registry on the pc. i saw no problem. all timezone entries are the same as on my pc.

But I found a workaround to set the timezone for my program which runs under WebStart. I found the solution in this forum, but I don't understand it:

1. Set the user.timezone Property in the jnlp:

<property name="user.timezone" value="Europe/Berlin"/>

2. Set the default timezone in the program like this:

TimeZone.setDefault(TimeZone.getTimeZone(System.getProperty("user.timezone")));

Strangely it doesn't work, if I set the property in the program, but it works via jnlp

Message was edited by:

dirkeiden

dirkeidena at 2007-7-12 21:42:31 > top of Java-index,Java Essentials,Java Programming...