Java Time Discrepancy

Discussion in 'Java' started by Karl Uppiano, Jul 8, 2007.

  1. Karl Uppiano

    Karl Uppiano Guest

    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?
     
    Karl Uppiano, Jul 8, 2007
    #1
    1. Advertisements

  2. Karl Uppiano

    Roedy Green Guest

    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.
     
    Roedy Green, Jul 8, 2007
    #2
    1. Advertisements

  3. Karl Uppiano

    Karl Uppiano Guest

    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.
     
    Karl Uppiano, Jul 8, 2007
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.