<p>I am running a Tomcat application, and I need to display some time values.  Unfortunately, the time is coming up an hour off.  I looked into it and discovered that my default TimeZone is being set to:</p>

<pre><code>sun.util.calendar.ZoneInfo[id="GMT-08:00",
                           offset=-28800000,
                           dstSavings=0,
                           useDaylight=false,
                           transitions=0,
                           lastRule=null]
</code></pre>

<p>Rather than the Pacific time zone.  This is further indicated when I try to print the default time zone's <a href="http://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#getDisplayName()" rel="noreferrer">display name</a>, and it comes up "GMT-08:00", which seems to indicate to me that it is not correctly set to the US Pacific time zone.  I am running on Ubuntu Hardy Heron, upgraded from Gutsy Gibbon.</p>

<p>Is there a configuration file I can update to tell the JRE to use Pacific with all the associated daylight savings time information?  The time on my machine shows correctly, so it doesn't seem to be an OS-wide misconfiguration.</p>

<hr>

<p>Ok, here's an update. A coworker suggested I update JAVA_OPTS in my /etc/profile to include "-Duser.timezone=US/Pacific", which worked (I also saw CATALINA_OPTS, which I updated as well). Actually, I just exported the change into the variables rather than use the new /etc/profile (a reboot later will pick up the changes and I will be golden).</p>

<p>However, I still think there is a better solution... there should be a configuration for Java somewhere that says what timezone it is using, or how it is grabbing the timezone. If someone knows such a setting, that would be awesome, but for now this is a decent workaround.</p>

<hr>

<p>I am using 1.5, and it is most definitely a DST problem.  As you can see, the time zone is set to not use daylight savings.  My belief is it is generically set to -8 offset rather than the specific Pacific timezone.  Since the generic -8 offset has no daylight savings info, it's of course not using it, but the question is, where do I tell Java to use Pacific time zone when it starts up?  I'm NOT looking for a programmatic solution, it should be a configuration solution.</p>

[{'answer_id': 6496, 'author': 'Jason Day', 'author_id': 737, 'author_profile': 'https://Stackoverflow.com/users/737', 'pm_score': 6, 'selected': True, 'text': '<p>It\'s a "quirk" in the way the JVM looks up the zoneinfo file.  See <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6456628" rel="noreferrer">Bug ID 6456628</a>.</p>\n\n<p>The easiest workaround is to make /etc/localtime a symlink to the correct zoneinfo file.  For Pacific time, the following commands should work:</p>\n\n<pre><code># sudo cp /etc/localtime /etc/localtime.dist\n# sudo ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime\n</code></pre>\n\n<p>I haven\'t had any problems with the symlink approach.</p>\n\n<p>Edit: Added "sudo" to the commands.</p>\n'}, {'answer_id': 6502, 'author': 'McDowell', 'author_id': 304, 'author_profile': 'https://Stackoverflow.com/users/304', 'pm_score': 0, 'selected': False, 'text': '<p>It may help to double-check the timezone rules your OS is using.</p>\n\n<pre><code>/usr/bin/zdump -v /etc/localtime | less\n</code></pre>\n\n<p>This file should contain your daylight savings rules, like this one for the year 2080:</p>\n\n<pre><code>/etc/localtime  Sun Mar 31 01:00:00 2080 UTC = Sun Mar 31 02:00:00 2080 BST isdst=1 gmtoff=3600\n</code></pre>\n\n<p>You can compare this with the timezone rules you think you should be using. They can be found in <strong>/usr/share/zoneinfo/</strong>.</p>\n'}, {'answer_id': 182437, 'author': 'abarax', 'author_id': 24390, 'author_profile': 'https://Stackoverflow.com/users/24390', 'pm_score': 2, 'selected': False, 'text': '<p>I had a similar issue, possibly the same one. However my tomcat server runs on a windows box so the symlink solution will not work. </p>\n\n<p>I set <code>-Duser.timezone=Australia/Sydney</code> in the <code>JAVA_OPTS</code> however tomcat would not recognize that DST was in effect. As a workaround I changed <code>Australia/Sydney</code> (GMT+10:00) to <code>Pacific/Numea</code> (GMT+11:00) so that times would correctly display however I would love to know the actual solution or bug, if any.</p>\n'}, {'answer_id': 3912695, 'author': 'Liu Zehua', 'author_id': 473064, 'author_profile': 'https://Stackoverflow.com/users/473064', 'pm_score': 5, 'selected': False, 'text': '<p>On Ubuntu, it\'s not enough to just change the /etc/localtime file. It seems to read /etc/timezone file, too. It\'s better follow the <a href="https://help.ubuntu.com/community/UbuntuTime" rel="noreferrer">instruction</a> to set the time zone properly. In particular, do the following:</p>\n\n<pre><code>$ sudo cp /etc/timezone /etc/timezone.dist\n$ echo "Australia/Adelaide" | sudo tee /etc/timezone\nAustralia/Adelaide\n$ sudo dpkg-reconfigure --frontend noninteractive tzdata\n\nCurrent default time zone: \'Australia/Adelaide\'\nLocal time is now:      Sat May  8 21:19:24 CST 2010.\nUniversal Time is now:  Sat May  8 11:49:24 UTC 2010.\n</code></pre>\n\n<p>On my Ubuntu, if /etc/localtime and /etc/timezone are inconsistent, Java seems to read default time zone from /etc/timezone .</p>\n'}, {'answer_id': 66403246, 'author': 'Sleem', 'author_id': 238813, 'author_profile': 'https://Stackoverflow.com/users/238813', 'pm_score': 0, 'selected': False, 'text': '<p>Adding a short answer that worked for me, you can use <code>timedatectl</code> to set the timezone. Then restart the JVM afterwards.</p>\n<pre class="lang-sh prettyprint-override"><code>sudo timedatectl set-timezone UTC\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/6392', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/122/']