@MinDoc(copyright="Copyright 2016 A. Weinert", author="Albrecht Weinert", version="V.33", lastModified="27.03.2021", usage="make read update read ....", purpose="a versatile Clock for real time applications") public final class SynClock extends Clock implements Serializable, AClock
java.time.Clock
for real time applications. It
provides readings of the time in different forms: as long (ms since
1.1.1070), Instant
,
ZonedDateTime
and else. All readings are
consistent with the last update()
.TimeHelper
,
Serialized FormModifier and Type | Field and Description |
---|---|
Clock |
clock
The underlying clock.
|
static long |
startAll
The common starting time (long).
|
static Instant |
startInstAll
The common starting time.
|
static FixClock |
startSys
The common starting time.
|
static ZonedDateTime |
startZoDtAll
The common starting time.
|
static SynClock |
sys
A SynClock with the target platform's system clock and local zone.
|
ZoneId |
zone
This Clock's / SynClocks's time-zone.
|
Modifier and Type | Method and Description |
---|---|
FixClock |
fix()
Provide another AClock with a fixed time according to current state.
|
ZonedDateTime |
getActTime()
The current zone related time of this SynClock.
|
ZonedDateTime |
getActTime(ZoneId zone)
The current zone related time of this SynClock.
|
ZoneId |
getZone()
The clock's time-zone.
|
Instant |
instant()
The current instant of this SynClock.
|
static SynClock |
make(Clock clock,
ZoneId zone)
Obtain a SynClock.
|
long |
millis()
The current time of this SynClock.
|
ZonedDateTime |
setActTime()
Update and get current zone related time of this SynClock.
|
Instant |
setInstant()
The updated instant of this SynClock.
|
String |
toString()
The state as String.
|
boolean |
update()
Update this SynClock to its current time.
|
SynClock |
withZone(ZoneId zone)
Provide another SysClock with a different time-zone.
|
equals, fixed, hashCode, offset, system, systemDefaultZone, systemUTC, tick, tickMinutes, tickSeconds
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
format, formatDIN, getDayOfMonth, getHour, getMilli, getMinute, getMonth, getMonthOfYear, getNano, getSecond, getYear, of, setActTimeMs
public static final SynClock sys
update()
,
setActTime()
or AClock.setActTimeMs()
, causing an update to the
ongoing system / platform time. The latter two methods are the only way to
change this common time stamp. getActTime()
and
millis()
will yield a common time stamp that has a
guaranteed monotony.public static final FixClock startSys
ZonedDateTime
startZoDtAll
as well as long startAll
.public static final Instant startInstAll
ZonedDateTime
startZoDtAll
as well as long startAll
.public static final ZonedDateTime startZoDtAll
Instant
startInstAll
.public static final long startAll
public final Clock clock
public final ZoneId zone
public static SynClock make(Clock clock, ZoneId zone)
Clock.systemDefaultZone()
will be used
for clock and zone. Clock.system(zone)
will be used.zone
- the time zone to useclock
- the underlying Clockupdated
to clock's actual timepublic ZoneId getZone()
ZonedDateTime
.
It is finally set at construction, never null and defaults to
clock's
zone.public Instant instant()
public Instant setInstant()
setInstant
in interface AClock
public long millis()
public ZonedDateTime getActTime()
getActTime
in interface AClock
zone
public ZonedDateTime setActTime()
updates
and returns
the actual
time.setActTime
in interface AClock
zone
public ZonedDateTime getActTime(ZoneId zone)
getActTime
in interface AClock
zone
- the zone to relate to; null will be this SynClock's zone
public boolean update()
public String toString()