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?

4/4/2019 5:04:26 PM

Sanjarbek Abdukhalilov

4 Answers

New Answer


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;






Google it