Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to get country name for a particluar TimeZone object??

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I need to develope a website which shows the client time and the client timezone. I get the Locale of client and time zone offset from javascript but I am not able to obtain exact time zone of client as an offset has multiple time zones. Please help me on this.
 
Sheriff
Posts: 21997
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your exact question? Your subject line is not related to your actual post.

The answer to the question in your subject line is simple: you can't. The reason is quite clear: a time zone does not have a specific country; many time zones are used in multiple countries. For instance, CET spans half of Europe.

About your second question: you say you have the offset, right? You can then create an instance of SimpleTimeZone using that offset.
 
sujay bawaskar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is the problem only, one Time zone offset spans over multiple timezone, hence i am not able to get exact timezone for my client side. If i get country for that timezone then i can figure it out.
 
Rob Spoor
Sheriff
Posts: 21997
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No you can't. Two good examples: the United States and Russia both span multiple time zones. In the end, there is a many-to-many relation between countries and time zones: a time zone can span multiple countries, and a country can span multiple time zones. The only way to get the correct time zone is to know the exact location; that is, the longitude and latitude. Some time zones do not run in parallel with meridians, so only the longitude is not enough.
 
sujay bawaskar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
 
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic