'How to set Oracle time zone region in tomcat

I have a tomcat5 server which connects to an Oracle DB and I like to specify the Oracle session time zone.

I managed to define it by adding JAVA_OPTS="$JAVA_OPTS -Duser.timezone=Europe/Zurich" to config file tomcat5.conf. Problem is when I query in Oracle SELECT SESSIONTIMEZONE FROM dual; I get +02:00

Currently this is OK, however it will become wrong in winter season when daylight-saving-time is off - unless I restart the tomcat server.

How can I set time zone to region name (e.g. Europe/Zurich) instead of UTC offset (like +02:00)? I would like to avoid running explicit ALTER SESSION SET TIME_ZONE = ...; in my Oracle.



Solution 1:[1]

Seriously, Tomcat5? Tomcat 5.5 has been decommissioned in 2012. Well, apart from that: I'd recommend to fix this in a different way: Storing Timezone-infested data in the backend is a huge mess, always. Thus, you should always purely store UTC and not worry about any daylight-saving, user's geolocation or current timezone, unless you're presenting the data to the user. Only then (and on input) can you relate it to the current timezone for the current user and transform to/from UTC accordingly.

Thus, the question that you ask might seem logical, but will lead to a lot of pain later. Save yourself the pain and go UTC on the backend.

You already know how to set Tomcat's default timezone, you might want to be able to handle user-specific timezones in addition, but that's a completely different beast.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Olaf Kock