Class Timer

java.lang.Object
solvers.utilities.Timer

public class Timer extends Object
The Timer object can receive "start" and "pause" commands. It can also return the time interval in various formats.
Author:
Michail Makaronidis, 2009, 2010
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates and initialises a Timer object.
    Timer(long interval)
    Creates and initialises a Timer object.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    This method returns the sum of time intervals in msecs between every start and pause of the timer.
    This method returns the sum of time intervals between every start and pause of the timer in a pretty form.
    void
    Stops the timer, i.e.
    void
    Starts the timer, i.e.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Timer

      public Timer()
      Creates and initialises a Timer object.
    • Timer

      public Timer(long interval)
      Creates and initialises a Timer object. The initial time interval is set equal to the argument interval.
      Parameters:
      interval - The desired interval in msecs
  • Method Details

    • start

      public void start()
      Starts the timer, i.e. sets the current time as the beginning of the interval.
    • pause

      public void pause()
      Stops the timer, i.e. sets the current time as the end of the interval.
    • getInterval

      public long getInterval()
      This method returns the sum of time intervals in msecs between every start and pause of the timer. The result is valid only if each start call is followed by a subsequent pause call.
      Returns:
      Time interval in msecs
    • getPrettyInterval

      public String getPrettyInterval()
      This method returns the sum of time intervals between every start and pause of the timer in a pretty form. The result is valid only if each start call is followed by a subsequent pause call.
      Returns:
      String representing the time interval in pretty form.