org.ckkloverdos.time
Class SimpleTimeCounter

java.lang.Object
  extended by org.ckkloverdos.time.SimpleTimeCounter

public class SimpleTimeCounter
extends java.lang.Object

A simple start-stop counter. Not-synchronized.

Author:
Christos KK Loverdos

Constructor Summary
SimpleTimeCounter()
          Creates a new instance and starts the counter immediately.
SimpleTimeCounter(boolean start)
          Creates a new instance, optionally starting the counter if start is true.
 
Method Summary
 long millis()
          If the timer has not been started, returns zero, otherwise returns the time of the last stop minus the time of the last start.
 java.lang.String millisInfo()
           
 long restart()
          Computes the same value as stop().
 double seconds()
           
 java.lang.String secondsInfo()
           
 void start()
          Starts the counter.
 long stop()
          Stops the counter and returns the time difference between now and the previous start() action.
 java.lang.String timeInfo()
          Returns a string representation of the time passed, in the format [x days,] HH:MM:SS.LLL, where LLL are the milliseconds and the rest is obvious :-).
 java.lang.String toString()
           
 java.lang.String unitsPerMillis(int units, java.lang.String unitsname)
           
 java.lang.String unitsPerSec(int units, java.lang.String unitsname)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleTimeCounter

public SimpleTimeCounter()
Creates a new instance and starts the counter immediately.


SimpleTimeCounter

public SimpleTimeCounter(boolean start)
Creates a new instance, optionally starting the counter if start is true.

Parameters:
start -
Method Detail

start

public void start()
Starts the counter.


stop

public long stop()
Stops the counter and returns the time difference between now and the previous start() action.


restart

public long restart()
Computes the same value as stop(). In effect it successively stops and starts the counter in one step.


millis

public long millis()
If the timer has not been started, returns zero, otherwise returns the time of the last stop minus the time of the last start. If the timer hasnot been stopped, then it returns the current time minus the time of the last start.


seconds

public double seconds()

secondsInfo

public java.lang.String secondsInfo()

millisInfo

public java.lang.String millisInfo()

timeInfo

public java.lang.String timeInfo()
Returns a string representation of the time passed, in the format [x days,] HH:MM:SS.LLL, where LLL are the milliseconds and the rest is obvious :-).


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

unitsPerSec

public java.lang.String unitsPerSec(int units,
                                    java.lang.String unitsname)

unitsPerMillis

public java.lang.String unitsPerMillis(int units,
                                       java.lang.String unitsname)


Copyright © 1999-2007 Christos KK Loverdos. All Rights Reserved.