You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jon Wingfield <jo...@mkodo.com> on 2004/11/18 13:51:37 UTC

[OT] Re: wrong time in Java Applications to my location (new Date())

The default timezone of a Sun JVM is determined by user locale settings. 
If the runtime can't determine a sensible timezone from those it 
defaults to GMT, which is 3hrs off from Brazilia time, i think.

Looking at the source of TimeZone it uses the following system properties:
user.timezone
user.country
java.home

If user.timezone is not set then a native call is made using 
user.country and java.home. I'm not sure what happens for a 
multi-timezone country like Brazil ;)

So you could:

1) pass in the user.timezone system property to the runtime.

2) Set your servers default timezone in code:

TimeZone.setDefault(TimeZone.getTimeZone(id));

where id is one of:

Brazil/DeNoronha
America/Sao_Paulo (probably the one you want or maybe Brazil/East)
America/Boa_Vista
Brazil/Acre or America/Rio_Branco

Are you running Tomcat as a service? If so, you may also want to check 
that the regional settings for the user running the service are also set 
to Brazilia.

I would also check what is actually being determined by the JVM. Do 
something like:

System.out.println(TimeZone.getDefault());
System.getProperties().list(System.out);

HTH,

Jon

Acácio Furtado Costa wrote:

> Hi  everybody
> 
>  
> 
>             We have a Tom Cat application Server 5.0.19 running in a Windows 2003 with a Sun JDK 1.4.2.
> 
>             We are having problems with  time of our Applications . The time is correct under SO but we have 3 hours of difference in the applications (+3).
> 
>  
> 
> Our offset time is Brasilia -3:00 in the Windows 2003 and Regional settings is Portuguese, Brazil.
> 
>  
> 
> The method TO GET SYSTEM TIME is new Date()
> 
>  
> 
> Any suggestion, How we setup server parameters or application (JVM) parameters to solve this problem?
> 
>  
> 
> Thanks a lot in advance
> 
>  
> 
> Acacio Furtado Costa
> Pesquisa e Tecnologia
> 
> GIA - Magnesita S/A
> *(0xx31) 3368-1349
> *  acacioc@magnesita.com.br
> 
>  
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org