Java Time Discrepancy

K

Karl Uppiano

I have a somewhat time-critical application (Java Standard Edition 1.6) that
uses the system time (System.getCurrentTimeMillis) in various forms, such as
creating Date objects initialized to the current time. I don't require high
precision, but I do require reasonable accuracy.

I noticed that my application was two minutes "off time", so I checked the
Windows time and found that it had synced with the NIST time servers a
couple of hours earlier. Windows was on time. How does Java chase platform
time?
 
R

Roedy Green

I noticed that my application was two minutes "off time", so I checked the
Windows time and found that it had synced with the NIST time servers a
couple of hours earlier. Windows was on time. How does Java chase platform
time?

In DOS and early versions of Windows, Windows kept two times, a more
accurate time of day CMOS clock and a less accurate timer based on
interval ticks every 54.9254 ms or 18.2065/sec.

Presumably Java would use the CMOS time of day clock.

It will be a native method. Perhaps you can trace or disassemble it.

How do you know the time was off by two minutes? Perhaps there is
some problem in your assumptions.
 
K

Karl Uppiano

Roedy Green said:
In DOS and early versions of Windows, Windows kept two times, a more
accurate time of day CMOS clock and a less accurate timer based on
interval ticks every 54.9254 ms or 18.2065/sec.

Presumably Java would use the CMOS time of day clock.

It will be a native method. Perhaps you can trace or disassemble it.

How do you know the time was off by two minutes? Perhaps there is
some problem in your assumptions.

Gagh! Yes, there was a problem in my assumptions. I should never type (or
think) at 03:00 in the AM. It turns out that unbeknownst to me, the personal
firewall on my client machine was blocking the Network Time Protocol, and
the system clock hadn't been successfully synchronized in months. The client
was the one that was off time; the server is just fine. Nothing to see here.
Move along.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top