I have to write a program that mimics a digital clock w/ seconds, minutes, and hours. I'm sure I can get the displays working on my own and everything. My concern: what is the most efficient way to check the time? Should I just do Thread.sleep for 1 second then update things accordingly? Or should I use Java's date and time classes to do this? If I use the date & time in, say, a while loop, it would be inefficient since I really only need to check to see if something is a new time every second.
BestJewSinceJC
700
Posting Maven
Recommended Answers
Jump to PostWouldn't be Timer more efficient?
Jump to PostThere are a couple of different ways you can do it. Either of the provided Timer classes can be used to schedule a repeated task to update your internal variables (i.e. seconds). You can read about when to use which here. Alternately, …
All 5 Replies
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
BestJewSinceJC
700
Posting Maven
BestJewSinceJC
700
Posting Maven
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.