public final class SystemClock extends Object implements TimeSource<Moment>
Represents a clock which is based on the clock of the underlying operating system.
The system property "net.time4j.systemclock.nanoTime"
controls if this clock is internally based on the expression
System.nanoTime() (if property is set to "true")
or System.currentTimeMillis() (default).
| Modifier and Type | Field and Description |
|---|---|
static SystemClock |
INSTANCE
Singleton-instance.
|
| Modifier and Type | Method and Description |
|---|---|
Moment |
currentTime()
Yields the current time.
|
long |
currentTimeInMicros()
Yields the current time in microseconds elapsed since
[1970-01-01T00:00:00,000000Z].
|
long |
currentTimeInMillis()
Yields the current time in milliseconds elapsed since
[1970-01-01T00:00:00,000Z].
|
static ZonalClock |
inLocalView()
Creates a local clock in system timezone.
|
static ZonalClock |
inZonalView(String tzid)
Creates a local clock in given timezone.
|
static ZonalClock |
inZonalView(TZID tzid)
Creates a local clock in given timezone.
|
public static final SystemClock INSTANCE
Singleton-instance.
public Moment currentTime()
TimeSourceYields the current time.
currentTime in interface TimeSource<Moment>UnixTime object or derivate)public long currentTimeInMillis()
Yields the current time in milliseconds elapsed since [1970-01-01T00:00:00,000Z].
Starting with version 1.1 this method always delegates to
System.currentTimeMillis().
currentTimeInMicros()public long currentTimeInMicros()
Yields the current time in microseconds elapsed since [1970-01-01T00:00:00,000000Z].
If this clock is based only on System.currentTimeMillis()
then this method will just multiply the millisecond value by factor
1000. On many operating systems the precision is limited to
milliseconds. This is even true if this clock is based on
System.nanoTime() because for purpose of calibration even
here the method System.currentTimeMillis() must be accessed
at least one time.
public static ZonalClock inLocalView()
Creates a local clock in system timezone.
Timezone.ofSystem()public static ZonalClock inZonalView(TZID tzid)
Creates a local clock in given timezone.
tzid - timezone idIllegalArgumentException - if given timezone cannot be loadedpublic static ZonalClock inZonalView(String tzid)
Creates a local clock in given timezone.
tzid - timezone idIllegalArgumentException - if given timezone cannot be loadedCopyright © 2014. All rights reserved.