Compartir a través de


IChronology.DateNow Method

Definition

Overloads

DateNow()

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

DateNow(Clock)

Obtains the current local date in this chronology from the specified clock.

DateNow(ZoneId)

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

DateNow()

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

[Android.Runtime.Register("dateNow", "()Ljava/time/chrono/ChronoLocalDate;", "GetDateNowHandler:Java.Time.Chrono.IChronology, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)]
public virtual Java.Time.Chrono.IChronoLocalDate? DateNow ();
[<Android.Runtime.Register("dateNow", "()Ljava/time/chrono/ChronoLocalDate;", "GetDateNowHandler:Java.Time.Chrono.IChronology, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)>]
abstract member DateNow : unit -> Java.Time.Chrono.IChronoLocalDate
override this.DateNow : unit -> Java.Time.Chrono.IChronoLocalDate

Returns

the current local date using the system clock and default time-zone, not null

Attributes

Remarks

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

This will query the Clock#systemDefaultZone() system clock in the default time-zone to obtain the current date.

Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.

Java documentation for java.time.chrono.Chronology.dateNow().

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

DateNow(Clock)

Obtains the current local date in this chronology from the specified clock.

[Android.Runtime.Register("dateNow", "(Ljava/time/Clock;)Ljava/time/chrono/ChronoLocalDate;", "GetDateNow_Ljava_time_Clock_Handler:Java.Time.Chrono.IChronology, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)]
public virtual Java.Time.Chrono.IChronoLocalDate? DateNow (Java.Time.Clock? clock);
[<Android.Runtime.Register("dateNow", "(Ljava/time/Clock;)Ljava/time/chrono/ChronoLocalDate;", "GetDateNow_Ljava_time_Clock_Handler:Java.Time.Chrono.IChronology, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)>]
abstract member DateNow : Java.Time.Clock -> Java.Time.Chrono.IChronoLocalDate
override this.DateNow : Java.Time.Clock -> Java.Time.Chrono.IChronoLocalDate

Parameters

clock
Clock

the clock to use, not null

Returns

the current local date, not null

Attributes

Remarks

Obtains the current local date in this chronology from the specified clock.

This will query the specified clock to obtain the current date - today. Using this method allows the use of an alternate clock for testing. The alternate clock may be introduced using Clock dependency injection.

Java documentation for java.time.chrono.Chronology.dateNow(java.time.Clock).

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

DateNow(ZoneId)

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

[Android.Runtime.Register("dateNow", "(Ljava/time/ZoneId;)Ljava/time/chrono/ChronoLocalDate;", "GetDateNow_Ljava_time_ZoneId_Handler:Java.Time.Chrono.IChronology, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)]
public virtual Java.Time.Chrono.IChronoLocalDate? DateNow (Java.Time.ZoneId? zone);
[<Android.Runtime.Register("dateNow", "(Ljava/time/ZoneId;)Ljava/time/chrono/ChronoLocalDate;", "GetDateNow_Ljava_time_ZoneId_Handler:Java.Time.Chrono.IChronology, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)>]
abstract member DateNow : Java.Time.ZoneId -> Java.Time.Chrono.IChronoLocalDate
override this.DateNow : Java.Time.ZoneId -> Java.Time.Chrono.IChronoLocalDate

Parameters

zone
ZoneId

the zone ID to use, not null

Returns

the current local date using the system clock, not null

Attributes

Remarks

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

This will query the Clock#system(ZoneId) system clock to obtain the current date. Specifying the time-zone avoids dependence on the default time-zone.

Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.

Java documentation for java.time.chrono.Chronology.dateNow(java.time.ZoneId).

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