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

How to set a timer for quiz in java?

It should be run when the user start the quiz after fill the information and it should be stop when the user finish. Do you have any idea?

4th Apr 2019, 5:04 PM
Sanjarbek Abdukhalilov
Sanjarbek Abdukhalilov - avatar
4 Answers
+ 2
System.currentTimeMillis() --> the difference between the current time and midnight, January 1, 1970 UTC, in milliseconds. long start = System.currentTimeMillis(); //your quiz long end = System.currentTimeMillis(); long time = end - start; If you get 0 use System.nanoTime() long start = System.nanoTime(); //your quiz long end = System.nanoTime(); long time = end - start;
4th Apr 2019, 7:56 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
https://code.sololearn.com/c0EphMK2NCt8/?ref=app
4th Apr 2019, 8:09 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
Google it
5th Apr 2019, 7:24 AM
HACK#
HACK# - avatar