-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jeff,

On 3/23/16 9:16 AM, Jeff Crump wrote:
> If you're connecting to a database you can set the timezone offset
> for that db session.

That is (a) not necessary and (b) probably won't help. OP is going to
have problems reading dates as input as well, so a db-only fix only
helps a little.

- -chris

> On Mar 23, 2016 8:12 AM, "Christopher Schultz"
> <ch...@christopherschultz.net> wrote:
> 
> Utkarsh,
> 
> On 3/23/16 3:27 AM, Utkarsh Dave wrote:
>>>> Thanks Chris and John for the response.
>>>> 
>>>> Chris - We do not use date formats to display
> 
> This is the root of your problem.
> 
>>>> , but we are facing issue like 
>>>> System.out.println(java.util.TimeZone.getDefault().getID());
>>>> //This prints UTC, which is incorrect
> 
> The default time zone of your application should not matter,
> though changing it midstream could seriously confuse things. If you
> have a rogue library that is changing the default timezone to UTC,
> then maybe you should run in UTC all the time to avoid
> unpredictability.
> 
>>>> System.out.println(System.getProperty("user.timezone"));
>>>> //which prints IST, that is correct
> 
> This setting isn't really relevant after the JVM initializes. 
> user.timezone just seeds TimeZone.getDefault.
> 
>>>> System.out.println(new java.util.Date().toString()); //prints
>>>> Mon Feb 08 10:42:18 UTC 2016.
> 
> You need to use a DateFormat with a TimeZone, then you'll get the 
> values you expect.
> 
>>>> After restarting tomcat things get reset. On one of the blogs
>>>> I found setting the default timezone at start time is: java 
>>>> -Duser.timezone=<server time>. I will try this.
> 
> It won't help.
> 
>>>> But didn't quiet understood that why suddenly when everything
>>>> works fine, one odd day the UTC time zone starts displaying.
> 
> Try running under a SecurityManager; you'll probably find a
> component that tries to set that system property. Go complain to
> whoever wrote that code.
> 
> -chris
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>> 
>> 
> 
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlbymA0ACgkQ9CaO5/Lv0PDYGgCgqtFF/u1g/qZUXZn5Zq20udAv
aB4AnA6ouK7YOze50wNTJgmnD9V0H4W9
=wmRF
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to