Package net.time4j.clock
Class AdjustableClock
java.lang.Object
net.time4j.clock.AbstractClock
net.time4j.clock.AdjustableClock
- All Implemented Interfaces:
TimeSource<Moment>
Allows miscellaneous adjustments to any clock.
Note: This class is immutable as long as the underlying time source is immutable.
- Since:
- 2.1
- Author:
- Meno Hochschild
-
Method Summary
Modifier and TypeMethodDescriptionYields the current time.boolean
int
hashCode()
static AdjustableClock
of(TimeSource<?> source)
Creates a new adjustable clock for given time source.static AdjustableClock
ofSystem()
Yields an adjustable clock around the standard system clock.toString()
For debugging purposes.withOffset(int offset, TimeUnit unit)
Creates an adjusted clock which displays the current time with given time shift.Creates a pulsed clock which only displays the current time in given pulse unit.Methods inherited from class net.time4j.clock.AbstractClock
inLocalView, inPlatformView, inZonalView, inZonalView
Methods inherited from interface net.time4j.base.TimeSource
currentInstant
-
Method Details
-
ofSystem
Yields an adjustable clock around the standard system clock.
The clock can be adjusted using the
with()
-methods.- Returns:
- adjustable clock wrapper
- Since:
- 2.1
- See Also:
SystemClock.INSTANCE
-
of
Creates a new adjustable clock for given time source.
After construction, the clock can be adjusted using the
with()
-methods.- Parameters:
source
- time source which shall be adjusted- Returns:
- new adjustable clock wrapper
- Since:
- 2.1
-
withPulse
Creates a pulsed clock which only displays the current time in given pulse unit.
- Parameters:
pulse
- new pulse- Returns:
- adjusted clock with given pulse
- Since:
- 2.1
-
withOffset
Creates an adjusted clock which displays the current time with given time shift.
- Parameters:
offset
- amount of shiftunit
- unit of shift- Returns:
- adjusted clock with given shift/offset
- Since:
- 2.1
-
currentTime
Description copied from interface:TimeSource
Yields the current time.
- Returns:
- current time in seconds (as
UnixTime
object or derivate)
-
equals
-
hashCode
public int hashCode() -
toString
For debugging purposes.
-