If you're connecting to a database you can set the timezone offset for that
db session.
On Mar 23, 2016 8:12 AM, "Christopher Schultz" <ch...@christopherschultz.net>
wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iEYEARECAAYFAlbylhYACgkQ9CaO5/Lv0PCsSgCfW01dGvPDrotqubZwGAJpRgua
> gGkAoK7H1teb2+1Yu6iIN43hvMngfp97
> =l5Q5
> -----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