I'm having weird problem with java TimeZone..
Calling TimeZone.getDefault() gives my local time zone, which has an ID "GMT+02:00". Funny thing is that this ID doesn't appear in a list provided by TimeZone.getAvailableIDs(). Apparently my zone appears to be "Etc/GMT+2".
I'm trying to populate a combo with time zones, but it's impossible to put a selection because GMT+02:00 is not in the list.. Anyone seen this problem? Any ideas?
Update:
The bottom line is - can't rely on ID strings, must go with the offset as display ID's may vary from system to system.
ECT - Europe/Paris. IET - America/Indiana/Indianapolis. IST - Asia/Kolkata. JST - Asia/Tokyo.
The Time zone ID column lists time zones, in boldface, and the locations within each time zone. The Raw offset column lists the difference, in hours and minutes, between Greenwich Mean Time (GMT) and the specified time zone.
Java For Testers UTC stands for Co-ordinated Universal Time. It is time standard and is commonly used across the world. All timezones are computed comparatively with UTC as offset.
GMT+02:00 is a custom ID, it won't appear in the output of TimeZone.getAvailableIDs()
(which is huge). What you could do is to ask the user to specify his offset first and then get the available IDs for the given offset. For example, for GMT+02:00, the following piece of code:
for (String string : TimeZone.getAvailableIDs(TimeZone.getTimeZone( "GMT+02:00").getRawOffset())) { System.out.println(string); }
gives the following output:
ART Africa/Blantyre Africa/Bujumbura Africa/Cairo Africa/Gaborone Africa/Harare Africa/Johannesburg Africa/Kigali Africa/Lubumbashi Africa/Lusaka Africa/Maputo Africa/Maseru Africa/Mbabane Africa/Tripoli Asia/Amman Asia/Beirut Asia/Damascus Asia/Gaza Asia/Istanbul Asia/Jerusalem Asia/Nicosia Asia/Tel_Aviv CAT EET Egypt Etc/GMT-2 Europe/Athens Europe/Bucharest Europe/Chisinau Europe/Helsinki Europe/Istanbul Europe/Kaliningrad Europe/Kiev Europe/Mariehamn Europe/Minsk Europe/Nicosia Europe/Riga Europe/Simferopol Europe/Sofia Europe/Tallinn Europe/Tiraspol Europe/Uzhgorod Europe/Vilnius Europe/Zaporozhye Israel Libya Turkey
It's still big but human browsable this time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With