Re: Wrong result from System.currentTimeMillis()



On 4 Gen, 04:24, Roedy Green <see_webs...@xxxxxxxxxxxxxxxxxxxx> wrote:
On Thu, 3 Jan 2008 04:16:08 -0800 (PST), alberto....@xxxxxxxxx wrote,
quoted or indirectly quoted someone who said :

They differ by about 1 hour (60 * 60 * 1000) as if
system clock was wrong but it isn't.

That sounds suspiciously like a daylight saving problem.

Did someone manually adjust the clock by one hour rather than setting
the timezone and letting the OS adjust?

In all your calculations, keep printing the timezone to make sure it
is what you think, also the various offsets. Seehttp://mindprod.com/jgloss/timezone.html
--
Roedy Green Canadian Mind Products
The Java Glossaryhttp://mindprod.com

As I said both system clock and TZ appear to be correct .

That's what this code fragment produces:

TimeZone tz1 = TimeZone.getDefault();
System.out.println(tz1.getDisplayName());
System.out.println(System.getProperty( "user.timezone" ));
System.out.println(new Date());

Central European Time
Europe/Rome
Fri Jan 04 09:22:36 CET 2008

While the OS date command produces:

Fri Jan 4 08:22:48 Europe/Rome 2008

(1 hour less)


N.B. the env command shows:

..
..
..
TZ=Europe/Rome
..
..




.