Does java have a class representing a timer?

I need a timer class that allows me to call:

.start() .getElapsedTime() .stop() .reset()

Does Java have such a class, or do I need to use my own (which I already wrote).

From a best practice point of view, I should use Java class classes, if they exist, but I'm not sure what this does.

Can someone give me a link to javadoc for this class if it exists?

+3
source share
3 answers

Apache Commons Lang has a class StopWatch.

To start the clock, call start(). At this point you can:

  • split() , , . unsplit() split. .
  • suspend() , . resume() . suspend resume . .
  • stop() , .

, toString() getTime() stop, split suspend, .

API


, , , . , , , Java . , , .

+2
+1

java.util.Timer.scheduleAtFixedRate(), : http://bugs.sun.com/view_bug.do?bug_id=4290274

-1

Source: https://habr.com/ru/post/1750054/


All Articles