| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.cleancode.time.SimpleFormat
public class SimpleFormat
Provides simple elapsed time formatting.
| Constructor Summary | |
|---|---|
| SimpleFormat()Creates a nominal SimpleFormat object. | |
| SimpleFormat(int speedup)Creates a SimpleFormat object with accelerated time. | |
| Method Summary | |
|---|---|
|  long | elapsed()Returns the elapsed time since object creation as a number. | 
|  Date | getEndDate()Returns Date object for end of interval. | 
|  Date | getStartDate()Returns Date object for start of interval. | 
|  boolean | isElapsed(long val)Indicates whether a given time has passed since object creation. | 
|  void | lap()Freezes the timer value to be returned. | 
|  String | reportElapsed()Reports the elapsed time since creation of the SimpleFormat object. | 
|  void | resume()Release the lock on the timer value set by lap(). | 
|  void | setFixedFormat()Change from minimal format (the default) to fixed format. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public SimpleFormat()
public SimpleFormat(int speedup)
speedup - time acceleration factor| Method Detail | 
|---|
public void setFixedFormat()
public String reportElapsed()
reportElapsed reports on the current
 date at the instant it is called 
 unless you have locked in a value with lap.
public boolean isElapsed(long val)
val - time to check, in milliseconds
public long elapsed()
elapsed reports on the current
 date at the instant it is called 
 unless you have locked in a value with lap.
 If the object has been created with accelerated time
 (see SimpleFormat(int), this routine reports
 time multiplied by that acceleration factor.
public Date getStartDate()
public Date getEndDate()
getEndDate reports on the current
 date at the instant it is called 
 unless you have locked in a value with lap.
 Also, be aware that, if using a time accelerated object,
 this endDate is the actual, unmodified one.
public void lap()
getEndDate or
 elapsed
 will normally report on the time at the current instant.
 Use this method to lock a value at a given moment in time.
 That way you can do other processing that you do not wish
 to be included in the timer results before actually
 asking for the timer results. (Also, that guarantees that
 both getEndDate and elapsed
 will be talking about exactly the same value; otherwise
 even if called consecutively, they will differ by a miniscule
 amount.) Use the corresponding resume method to
 unlock the timer, so that you may get a fresh value later
 via either getEndDate, elapsed,
 or lap itself.
public void resume()
lap().
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
| CleanCode Java Libraries | Copyright © 2001-2012 Michael Sorens - Revised 2012.12.10 |