I wanna make a game where the speed be a matter of CPU speed so I need to get the currentTime from the SYstem. How do I do that?
Use the following System.currentTimeMillis() .
It returns the current time in milliseconds, so a value of 1000 is 1 second.
;D
Simon
Starting with Java 1.5 you could use
long time = System.nanoTime()
to get a 10^-9 seconds resolution which is more accurate than the currentTimeMillis() call.
[quote] long time = System.nanoTime()
[/quote]
Would somebody know how accurate is that function? Does it use CPU counters as discussed in this thread?
The API says that “This method provides nanosecond precision, but not necessarily nanosecond accuracy. No guarantees are made about how frequently values change.” So what is the accuracy of the implementations on Windows and Linux machines?
it’s the most accurate time you can get for comparison purposes 