Language

Clock.Offset(Clock, Duration) Method

Definition

Obtains a clock that returns instants from the specified clock with the specified duration added.

[Android.Runtime.Register("offset", "(Ljava/time/Clock;Ljava/time/Duration;)Ljava/time/Clock;", "", ApiSince=26)]
public static Java.Time.Clock? Offset(Java.Time.Clock? baseClock, Java.Time.Duration? offsetDuration);
[<Android.Runtime.Register("offset", "(Ljava/time/Clock;Ljava/time/Duration;)Ljava/time/Clock;", "", ApiSince=26)>]
static member Offset : Java.Time.Clock * Java.Time.Duration -> Java.Time.Clock

Parameters

baseClock
Clock

the base clock to add the duration to, not null

offsetDuration
Duration

the duration to add, not null

Returns

a clock based on the base clock with the duration added, not null

Attributes

Remarks

Obtains a clock that returns instants from the specified clock with the specified duration added. This clock wraps another clock, returning instants that are later by the specified duration. If the duration is negative, the instants will be earlier than the current date and time. The main use case for this is to simulate running in the future or in the past. A duration of zero would have no offsetting effect. Passing zero will return the underlying clock. The returned implementation is immutable, thread-safe and Serializable providing that the base clock is.

Java reference for java.time.Clock.offset.

Applies to