You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vernon _ <vw...@hotmail.com> on 2007/04/18 17:20:23 UTC

Why the time is way off?

The time in my Java web applications is way off the mark. For example, the time on the log4j message file is Apr 18 13:44 when the time on the Linux box is Apr 17 21:44. The applications use the same time data of log4j. There is not such issue in the development Window box, but only on the deployment Linux box. The applications don't change the time setting, nor the time zone. I have to ask whether it is possible that TC can be configured with different time set as its underlaid OS or not. Is a way to find out the time setting in a TC? I don't have a control of TC on the deployment box, btw.Thanks,Vernon
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

Re: Why the time is way off?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vernon,

Vernon _ wrote:
> The time in my Java web applications is way off the mark. For
> example, the time on the log4j message file is Apr 18 13:44 when the
> time on the Linux box is Apr 17 21:44.

The (lack of) minute differential is an indication that when you run
"date" from the command-line you are getting one timezone, and the JVM
is using another one.

Run "date" from the command line and see what timezone is displayed. For
instance, when I run "date" with no arguments, I get this:

Wed Apr 18 13:07:26 EDT 2007

So my timezone is EDT (UTC - 0400).

Depending on your Linux distribution, you can change the timezone for
the OS in different ways. I use Gentoo Linux which uses /etc/localtime
as a symlink to the real timezone definition file located in the
/usr/share/zoneinfo directory.

The JVM lets you set the timezone of the JVM by using the user.timezone
system property. You can also read that property to see what timezone is
being used by the JVM.

> The applications don't
> change the time setting, nor the time zone.

Your JVM may have a differently configured timezone or the config might
be broken, causing it to default to UTC.

> I have to ask whether it
> is possible that TC can be configured with different time set as its
> underlaid OS or not.

Absolutely... using the user.timezone system property. You can set this
in your startup.sh file or probably using "export
JAVA_OPTS=-Duser.timezone=???" and then running startup.sh.

> Is a way to find out the time setting in a TC?

System.err.println(new Date()) ought to print the timezone.

> I don't have a control of TC on the deployment box, btw.

That could be a problem. I'm not sure if you can change the value of
user.timezone at runtime. You can always try ;) If not, you will either
have to get your system administrators to fix the TC timezone setting or
just deal with the incorrect timezone.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGJlIO9CaO5/Lv0PARArvcAJ9WsVtypQ4/Lhl4mvBcyiloEkvVkACfQdZl
qYxBO0ltOJyHkW94LRQownU=
=Bbqj
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org