How to make a clock in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to make a clock in java

which change its time every second

2nd Jul 2017, 2:26 PM
Code_adi
Code_adi - avatar
3 Answers
+ 1
create a loop that will go on until the program is executed. use System.currentTimeMillis() to get the current time on your computer use something like an if statement to check when that time has been passed by 1000 milliseconds, and every time 1000 milliseconds passes use a variable called seconds that will increment by one each time, this will create a timer. You can System.out.println(), or display in a window, the number of seconds every time that number updates. The source code would be pretty complex and take a while to program but I hope this gives you a good starting point!
2nd Jul 2017, 3:03 PM
Amado Marquez
Amado Marquez - avatar
0
theard.sleep(10) can be the alternative
2nd Jul 2017, 3:27 PM
Code_adi
Code_adi - avatar
0
I thought so
2nd Jul 2017, 3:28 PM
Code_adi
Code_adi - avatar