JVM timing problem

Hello,

we encounter a time synchronisation problem with the call System.currentTimeMillis(). My guess is, that it has to do with the virtual enviroments (HP/UX machine, with a couple of virtual oracle enviroments).

we can see a time difference between different Oracle containers. In a couple of weeks the difference off a timestamp can be 17 seconds . . . one time even -10 seconds.

That's why we made an simple servlet to write a file with the date-time as a filename. The first day we saw that the time difference was a couple of milleseconds, but after the 2nd day we had a time gap off 3 seconds. The 3rd day, 5 seconds .. but the 4th day: 2 seconds gap .. I compare the file name, with the OS time stamp of the modified attribute.

The simple code in the servlet:

Date date = new Date();

bestandsNaam = date.toString();

FileWriter writer = new FileWriter(directory+formatter.format(date)+".txt");

writer.close();

Can someone tell me if this can be a jvm issue (we use the Oracle variant: ojvm)

I hope that someone recognizes this problem.

Thnx in advance

[1134 byte] By [LooyeDa] at [2007-11-27 0:06:39]
# 1

> can someone tell me if this can be a jvm issue (we use

> the Oracle variant: ojvm)

>

It all likelyhood it is an application problem. Since java is an application it falls into that category. Other apps could have the same problem.

An application uses the normal OS time facilities. On start up those are initialized using the system clock. They however do not continue to use the system clock. Instead they use a system interrupt/timer/etc to update a cached value. The implemented method is not as precise as the hardware clock (or at the very least not in sync with it.) So over time they get out of sync.

One solution is to just restart the app every day. Alternatively you have to implement your own time solutions or find one from some other source.

jschella at 2007-7-11 16:04:18 > top of Java-index,Java HotSpot Virtual Machine,Specifications...