This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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