org.nakedobjects.applib.clock
Class Clock

java.lang.Object
  extended by org.nakedobjects.applib.clock.Clock
Direct Known Subclasses:
FixtureClock

public abstract class Clock
extends java.lang.Object

Provides a mechanism to get (and possible to set) the current time.

The clock is used primarily by the temporal value classes, and is accessed by the NOF as a singleton. The actual implementation used can be configured at startup, but once specified the clock instance cannot be changed.

Unless another Clock implementation has been installed, the first call to getInstance() will instantiate an implementation that just uses the system's own clock. Alternate implementations can be created via suitable subclasses, but this must be done before the first call to getInstance(). See for example getInstance().


Constructor Summary
protected Clock()
           
 
Method Summary
static Clock getInstance()
          Returns the (singleton) instance of Clock.
static long getTime()
           
static java.util.Calendar getTimeAsCalendar()
           
static boolean isInitialized()
          Whether has been initialized or not.
protected static boolean remove()
          Allows subclasses to remove their implementation.
protected abstract  long time()
          The current time since midnight, January 1, 1970 UTC.
 java.util.Calendar timeAsCalendar()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Clock

protected Clock()
Method Detail

getInstance

public static final Clock getInstance()
Returns the (singleton) instance of Clock.

Unless it has been otherwise created, will lazily instantiate an implementation that just delegate to the computer's own system clock (as per System.currentTimeMillis().

Returns:

isInitialized

public static boolean isInitialized()
Whether has been initialized or not.


getTime

public static long getTime()

getTimeAsCalendar

public static java.util.Calendar getTimeAsCalendar()

remove

protected static boolean remove()
Allows subclasses to remove their implementation.

Returns:
whether a clock was removed.

timeAsCalendar

public final java.util.Calendar timeAsCalendar()

time

protected abstract long time()
The current time since midnight, January 1, 1970 UTC.

Measured in milliseconds, modeled after (and possibly implemented by) System.currentTimeMillis().



Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.