OffsetDateTime.Now Method

Definition

Overloads

Name Description
Now(Clock)

Obtains the current date-time from the specified clock.

Now(ZoneId)

Obtains the current date-time from the system clock in the specified time-zone.

Now()

Obtains the current date-time from the system clock in the default time-zone.

Now(Clock)

Obtains the current date-time from the specified clock.

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

Parameters

clock
Clock

the clock to use, not null

Returns

the current date-time, not null

Attributes

Remarks

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

Java reference for java.time.OffsetDateTime.now.

Applies to

Now(ZoneId)

Obtains the current date-time from the system clock in the specified time-zone.

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

Parameters

zone
ZoneId

the zone ID to use, not null

Returns

the current date-time using the system clock, not null

Attributes

Remarks

Obtains the current date-time from the system clock in the specified time-zone. This will query the system clock to obtain the current date-time. Specifying the time-zone avoids dependence on the default time-zone. The offset will be calculated from the specified time-zone. Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.

Java reference for java.time.OffsetDateTime.now.

Applies to

Now()

Obtains the current date-time from the system clock in the default time-zone.

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

Returns

the current date-time using the system clock, not null

Attributes

Remarks

Obtains the current date-time from the system clock in the default time-zone. This will query the system clock in the default time-zone to obtain the current date-time. The offset will be calculated from the time-zone in the clock. Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.

Java reference for java.time.OffsetDateTime.now.

Applies to