• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

currentTimeMillis()

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic