permaculture playing cards*
The moose likes Java in General and the fly likes To extract the timezone from the system Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "To extract the timezone from the system" Watch "To extract the timezone from the system" New topic
Author

To extract the timezone from the system

yathish Gatty
Ranch Hand

Joined: Oct 05, 2004
Posts: 31
Hi all,

I am able to extract the timezone from the sytem when the system has the operating system WINDOWS XP, the timezone contains places with time but i am not able to get the timezone that will contain places with time when the system has WINDOWS 2000.

suppose i have set my system to Windows XP and I have set my system timezone to [(GMT+01:00)Amsterdam,Berlin] and by using the code i am getting the string as "Europe/Berlin". But if i set my system to Windows 2000 and set my system timezone to [(GMT+01:00)Amsterdam,Berlin] and by using the code i am getting only [(GMT+01:00)] but i need the place .
Please send me the code to obtain the places in WINDOWS 2000.

I am sending my code below:


TimeZone str=cal.getTimeZone();
localZonFromSyst=str.getID();
System.out.println(" the place is :" localZonFromSyst);


With Regards
Yathish
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
How Timezones are reported are system specific, It will report what ever String is given by the operating system. Only two pieces of data should be consistant across all systems, getRawOffset() which returns the millisecs offset from GMT without regard to Daylight savings time and getDSTSavings() which returns the number of millisecs that timezones uses for Daylight savings.

If you need to print out the Country a person has thier system set to, you need to use Locale.

System.out.println(Locale.getDefault().getCountry());


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: To extract the timezone from the system
 
Similar Threads
Force JVM default TimeZone on Windows start/login
Windows SBS 2008 and timezone (DST) problem in Europe/Berlin
Calendar() / Date() bug ???
Gregorian roll() function- April Fools Bug??
Communique & WebSphere 5.0