Field Detail

INSTANCE

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). The standard case is a clock which is affected by
OS-triggered time jumps and user adjustments so there is no guarantee for a monotonic time.

MONOTONIC

Monotonic clock based on the best available clock of the underlying operating system.

A side effect of this implementation can be increased nominal precision up to nanoseconds
although no guarantee is made to ensure nanosecond accuracy. The accuracy is often limited to
milliseconds. However, the main focus and motivation is realizing a monotonic behaviour by
delegating to the use of a monotonic clock of the underlying OS. Equivalent to CLOCK_MONOTONIC
on a Linux-server.

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.

Returns:

count of microseconds since UNIX epoch without leap seconds

realTimeInMicros

public long realTimeInMicros()

Yields the current time in microseconds elapsed since
UTC epoch [1972-01-01T00:00:00,000000Z].

inPlatformView

Uses the standard clock SystemClock.INSTANCE and the platform timezone data.

Background: Some mobile devices might have outdated or wrong timezone data but still display
the correct local time because they compensate the wrong zone information by adjusting the clock.
This method can help in such a situation, for example:

// we assume/know that the local device time is correct...
PlainTimestamp localTimestamp = SystemClock.inPlatformView().now();
// ...and then we combine correct local device time with the valid timezone data of Time4J
Moment nowCorrect = localTimestamp.inStdTimezone();

recalibrated

This method is only relevant if this clock is operated in monotonic mode. It is strongly advised
not to recalibrate during or near a leap second. Please also note that this method might cause jumps
in time - even backwards.

synchronizedWith

Synchronizes this instance with given time source and yields a new copy.

This method is only relevant if this clock is operated in monotonic mode. It is strongly advised
not to recalibrate during or near a leap second. Please also note that this method might cause jumps
in time - even backwards.