• 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
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

best way to locate a time zone in Europe?

 
author & internet detective
Posts: 41763
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was trying to write a program that involves the time zone in Germany. (It's an exercise in Cay Horstmann's book). Since I didn't know the time zone identifier for Germany, I wrote a line of code to spit out all the European time zones:



Then I picked Berlin because I know it is in Germany. This doesn't feel like an efficient way of finding out this information. Is there a "standard" list/map of time zones people in Europe use? For example, in the US.

Granted I don't do this often and my approach worked. But it did get me curious.
 
Saloon Keeper
Posts: 15253
349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not really an issue over here, because most countries here are only in one time zone, and we rarely need to deal with time zones of other countries.

If I do need to find out a specific time zone, I just hit Google. The first few site provide plenty of information, and Google Images shows maps of time zones.

Is there a reason you need Europe/Berlin over CEST?
 
Jeanne Boyarsky
author & internet detective
Posts: 41763
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:It's not really an issue over here, because most countries here are only in one time zone, and we rarely need to deal with time zones of other countries.


Funny. That's the same reason I don't know. (As someone in the US, I rarely deal with time zones in other countries.)

Stephan van Hulst wrote:Is there a reason you need Europe/Berlin over CEST?


Because I don't know any better? It doesn't matter for my toy program. I suspect I do want CEST (central european standard time) because my question was about more general time zones. And because I can't find CEST in the list of Java time zones.

1) There's nothing with CEST in the name.

2) Here's what the choices are for names containing Central (clearly not the answer:)


3) And here's what the choices are for names containing Europe:
 
Stephan van Hulst
Saloon Keeper
Posts: 15253
349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, well after doing a little bit of research, you probably want your program to work properly all year round, so CEST won't do (CEST stands for Central European Summer Time, which is only used during the summer). For the same reason, neither will CET because in most European countries it's only used during the winter.

Instead, you can use whatever time zone you want that obeys Daylight Saving Time. In the Netherlands, we usually use Europe/Amsterdam or Europe/Paris and I've even seen Europe/Madrid. Europe/Berlin or Europe/Hessen would also work.
 
Stephan van Hulst
Saloon Keeper
Posts: 15253
349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm the Java 8 time package is quite interesting. Here's a method that will print the local time for a given Clock. You can imagine a Clock being like a physical clock on a wall somewhere, using that time zone.
 
Jeanne Boyarsky
author & internet detective
Posts: 41763
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. That requires you to know which time zone you want though!
 
Master Rancher
Posts: 4658
62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, the problem of identifying your correct time zone from among the various candidate ids - that hasn't really changed since Java's inception. It's really all from the tz database - I like using the list here. The [continent]/[city] IDs (like America/Los_Angeles) seem to offer the most comprehensive list of options, but can be hard to navigate for folks not very familiar with the region in question. the [country]/[specifier] IDs (like US/Pacific) are much more readable, at least for the US - but Europe doesn't seem to have an equivalent. Too bad.
 
Stephan van Hulst
Saloon Keeper
Posts: 15253
349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interestingly, when I print the time zone that my system uses, it says Europe/Berlin. Windows lumps Amsterdam, Berlin, Bern, Rome, Stockholm and Vienna together. What makes it more interesting is that Windows also lumps Brussels, Copenhagen, Madrid and Paris together in a separate category.
 
Jeanne Boyarsky
author & internet detective
Posts: 41763
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stephan,
That would be more interesting if I had a map in front of me . I do recognize the countries they are from, but not the time zones they are in. [teasing - I did look at a map]
 
Marshal
Posts: 78659
374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote: . . . Brussels, Copenhagen, Madrid and Paris together in a separate category.

What about Lisbon? At the risk of being moved to MD, why does Portugal which is far west of Britain use a time zone one hour ahead of us?
 
Stephan van Hulst
Saloon Keeper
Posts: 15253
349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They don't. They're in the same time-zone: WET in the winter and WEST in the summer. France and Spain however should also be in WET/WEST, except they're problably in CET/CEST to adapt to the rest of mainland Europe.

If you try to change the time zone of your Windows clock, you'll notice that Lisbon and London are in the same option.
 
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:Yeah, the problem of identifying your correct time zone from among the various candidate ids - that hasn't really changed since Java's inception. It's really all from the tz database - I like using the list here. The [continent]/[city] IDs (like America/Los_Angeles) seem to offer the most comprehensive list of options, but can be hard to navigate for folks not very familiar with the region in question. the [country]/[specifier] IDs (like US/Pacific) are much more readable, at least for the US - but Europe doesn't seem to have an equivalent. Too bad.


new GregorianCalendar(locale).getTimeZone()?
 
Campbell Ritchie
Marshal
Posts: 78659
374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. I was obviously mistaken there.
 
Mike Simmons
Master Rancher
Posts: 4658
62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dieter Quickfend wrote:

Mike Simmons wrote:Yeah, the problem of identifying your correct time zone from among the various candidate ids - that hasn't really changed since Java's inception. It's really all from the tz database - I like using the list here. The [continent]/[city] IDs (like America/Los_Angeles) seem to offer the most comprehensive list of options, but can be hard to navigate for folks not very familiar with the region in question. the [country]/[specifier] IDs (like US/Pacific) are much more readable, at least for the US - but Europe doesn't seem to have an equivalent. Too bad.


new GregorianCalendar(locale).getTimeZone()?


Nope. This still uses the default time zone, ignoring locale. If I do this with Locale.CHINA, I get the America/Denver time zone.

Also, GregorianCalendar is evil, and if we're using Java 8, we wish to avoid it at any cost.
 
Jeanne Boyarsky
author & internet detective
Posts: 41763
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:Also, GregorianCalendar is evil, and if we're using Java 8, we wish to avoid it at any cost.


Definitely! I'm really impressed with the Java 8 time classes.

All: Interesting discussion about time zones.
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic