Reputation: 43159
We have seen a strange issue on some Windows XP machines involving the "Co-ordinated Universal Time" time zone. Not all Windows XP machines seem to have it, but on those that do, the following simple Java program
public class TimeTest {
public static void main(String[] args) {
System.out.println(java.util.TimeZone.getDefault());
System.out.println(new java.util.Date());
}
}
on JDK 1.6.0_06 prints:
sun.util.calendar.ZoneInfo[id="America/Caracas",offset=-16200000,dstSavings=0,useDaylight=false,transitions=5,lastRule=null] Fri Nov 13 05:34:14 VET 2009
(i.e. 4 and a half hours behind GMT). I should add that I am based in London, and have never been to South America. :-)
My questions are:
Upvotes: 5
Views: 2570
Reputation: 153
I experienced Java seeing a time zone of Venezuelan Standard Time (VET) even though Windows was set for Pacific. This was on a newly cloned VMWare box. Once I changed the time zone from Pacific to something else, saved it, changed it back to Pacific, saved it, then restarted my Java application, Java then recognized the correct time zone.
Upvotes: 3
Reputation: 1
I got the same problem in a Unix/Solaris. The date command use a Time/Zome variable when a comand like these "date -u 042315232010". If you use the parameter -u the comand date use a variable named TZ and it proced to ajust the GMT time against those in TZ. To solve these use the comand "date 042315232010" and all worked. Perhaps you should avoid TimeZone sentences in your Java program. By the way "date 042315232010" means "Fri Apr 23 15:23:00 VET 2010".
Upvotes: 0
Reputation: 1500515
It's printing out it using the default time zone. Your subject talks about "choosing" UTC, but I don't see any such choice in your program. If you've chosen it somewhere else, please give details of exactly where. If you've changed the XP time zone, you may want to try rebooting - it's possible that your Java code is getting a cached value from somewhere.
Print out java.util.TimeZone.getDefault
and I suspect you'll see VET on the machines with the problem.
If you want your code to use UTC, you should specify that explicitly... preferably using Joda Time instead of the built-in Date
/Calendar
classes.
EDIT: If you have .NET 3.5 on the same machines, try this little program to see what it thinks the time zone is:
using System;
class Test
{
static void Main()
{
Console.WriteLine(TimeZoneInfo.Local.DisplayName);
}
}
Upvotes: 0