This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes currentTimeMillis() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "currentTimeMillis()" Watch "currentTimeMillis()" New topic
Author

currentTimeMillis()

Andy Sabb
Greenhorn

Joined: Jul 15, 2001
Posts: 4
Hi there, I'm new and never posted here, so feel free to kick me any time, and have fun with me .
ok, done presentations, mine is a tiny question (-bows to java gurus-):
Why when I call System.currentTimeMillis() it returns me a long which always ends in 0 ? Moreover a thread waiting, say, 5 millis and then displaying the time cycles an average of 10 times with the same value (that is changes every 50 ms).
Shouldn't the method return in millisecond precision ? Or is there (surely) something I fail to get ?
Thanks for your time,
Andy
Art Metzer
Ranch Hand

Joined: Oct 31, 2000
Posts: 241
I think the phenomenon you report is a limitation of your operating system, not of Java.
While Java has the capability of reporting millisecond precision, your specific machine's resolution of time is to the hundredth of a second.
Hence System.currentTimeMillis() % 10 == 0 in your case.
Art
Andy Sabb
Greenhorn

Joined: Jul 15, 2001
Posts: 4
Shees ! I almost fell from my chair. I need some icecream
Well, thanks, but then why on earth this program:

gives this as a result ?

I am still completely at loss...
Thanks again
Andy
 
GeeCON Prague 2014
 
subject: currentTimeMillis()