• 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

Java 8 Time Zone

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey All,

I was going through the new features that are introduced in Java 8 and was glad to know that Java 8 has a new TimeZone feature which calculates the time difference between two time zones given the region as given in the following link

https://docs.oracle.com/javase/tutorial/datetime/iso/examples/Flight.java

But, there are only specific predefined regions like "Europe/Paris" or "America/New_York" that we can pass to get the zone. I can't pass any region/city as in

for example : French Polynesia has a city called "Anaa" and the region is "Frenh Polynesia". But when I pass "French Polynesia/Anaa" or "Europe/Anaa" or "France/Anaa" to the timezone as argument. It gives an exception.

Is there any way I can use this Java8 feature to get timezone of any region/city.

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those are timezone IDs, not arbitrary region and city names. You can't pass any arbitrary region and city name.

You can get all the timezone IDs that Java supports by calling: ZoneId.getAvailableZoneIds(). As the JavaDoc of ZoneId explains, these IDs come from the IANA Time Zone Database.

There is no Java API to get the timezone of any arbitrary city that is not in the list.
 
reply
    Bookmark Topic Watch Topic
  • New Topic