Re: Wrong result from System.currentTimeMillis()
alberto.poz@gmail.com wrote:
Actually I forget to specify that my RedHat is a VMware virtual
appliance.
Ahhhhh. So it's a virtual OS. I really have no idea how that would affect the
hardware clock and its interpretation by the Linux kernel.
That's what I can get from OS:
# uname -a
Linux sec-rfid-prod 2.6.9-42.0.3.EL #1 Mon Sep 25 17:14:19 EDT 2006
i686 i686 i386 GNU/Linux
# cat /etc/sysconfig/clock
ZONE="Europe/Rome"
UTC=true
ARC=false
Try setting the clock to UTC=false, the hardware clock is probably set to local
time if it's running under VMware, but check it. Don't edit this file, use
system-config-date and in the Time Zone tab uncheck the "System clock uses UTC"
checkbox.
# hwclock
Mon 07 Jan 2008 01:10:04 PM Europe/Rome -0.454620 seconds
# date +%s
1199711211
System.currentTimeMillis()
1199711210192
(they seem to be equal ...)
Not exactly equal. Which did you output first? The date value is 1 second after
the Java value, if you output date first how has your clock gone backward?
The important point, though, is that value is for 13:06:51 UTC, i.e. 14:06:51
CET. So it looks like Java is correct, and date is wrong.
Can you suggest me any other thing to check?
Not really. I don't have VMware so can't check anything.
--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555