• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

To know Timezone given City,State/Province,Country

 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am trying to look for some way to know the following information,

- Given City,State/Province,Country know the Timezone it belongs to at the time of the query

I found following links so far which is a good source of information BUT wanted to get somebody else's input if you have any experience on it.

StackOverflow Post

Thanks
Maulin
 
Ranch Hand
Posts: 92
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Maulin,

If you look at the getTimeZone() method of the Calendar class clearly you can see there is a way to get a TimeZone from a given Calendar.

The trick is to get an appropriate calendar instance using the getInstance() method of Calendar, passing in a Locale.

Unfortunately that'll not help down to the city level. The above will only work for countries. SO why not try the likes of Joda Time as suggested here?

I hope this helps,

John
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic