Instant.Now Method

Definition

Overloads

Name Description
Now()

Obtains the current instant from the system clock.

Now(Clock)

Obtains the current instant from the specified clock.

Now()

Obtains the current instant from the system clock.

[Android.Runtime.Register("now", "()Ljava/time/Instant;", "", ApiSince=26)]
public static Java.Time.Instant? Now();
[<Android.Runtime.Register("now", "()Ljava/time/Instant;", "", ApiSince=26)>]
static member Now : unit -> Java.Time.Instant

Returns

the current instant using the system clock, not null

Attributes

Remarks

Obtains the current instant from the system clock. This will query the system UTC clock to obtain the current instant. Using this method will prevent the ability to use an alternate time-source for testing because the clock is effectively hard-coded.

Android reference for java.time.Instant.now.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Now(Clock)

Obtains the current instant from the specified clock.

[Android.Runtime.Register("now", "(Ljava/time/Clock;)Ljava/time/Instant;", "", ApiSince=26)]
public static Java.Time.Instant? Now(Java.Time.Clock? clock);
[<Android.Runtime.Register("now", "(Ljava/time/Clock;)Ljava/time/Instant;", "", ApiSince=26)>]
static member Now : Java.Time.Clock -> Java.Time.Instant

Parameters

clock
Clock

Clock: the clock to use, not null

Returns

the current instant, not null

Attributes

Remarks

Obtains the current instant from the specified clock. This will query the specified clock to obtain the current time. Using this method allows the use of an alternate clock for testing. The alternate clock may be introduced using dependency injection.

Android reference for java.time.Instant.now.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to