This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to read system clock?

 
Ilya PA
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm wrighting a program that requires accurate readings from the system clock... is there an way to do it? I was trying to use the java.util.Calendar class, as follows:
...
Calendar clock=Calendar.getInstance();
long time=clock.getTimeInMillis();
...
But if i try to check the time in the same method again it gives me the same result... How come? Is there a way to overcome this?
 
Dan Cranmer
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works for me?

System.currentTimeMillis(); might be a little easier to use. For more accurate timing see http://www.boulder.nist.gov/timefreq/service/its.htm
[ August 30, 2002: Message edited by: Dan Cranmer ]
 
Ilya PA
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx alot, that bit of code was of great help~! It pointed me out my mistake of getting only one instance of calendar and then enquiring it for time, but i should have gotten a new instance each time!
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ilya,
Please change your name to be compliant with JavaRanch's naming policy.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.
Thanks,
Cindy
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic