• Post Reply Bookmark Topic Watch Topic
  • New Topic

timezones for a country  RSS feed

 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi -

Is there a way to get all the timezones that belong to a country in Java? I know there no direct method in the java.util.TimeZone class but wondering if there is a workaround.

Thanks!
 
Paul Clapham
Sheriff
Posts: 22834
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.

What exactly is it you need a "workaround" for?
 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I meant - can we write our own function to do that?

for example -

I tried to get all available timezones and checked if the raw offset falls within a range of US timezones but noticed that it is also returning Mexican timezones.
I tried to parse for the string "America/" but there could other timezone strings that satrt with "America/" that do not belong to US.

Badly need to do this using JDK.
 
Paul Clapham
Sheriff
Posts: 22834
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure you can. You list out all of the possible time zones (there are several hundred of them if I recall right). Then for each of them you write down which countries they apply to. Then you set up some kind of table which encapsulates that information, and have your function access that table.

What I meant was why you needed this information?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!