Language

ZonedDateTime.OfLocal(LocalDateTime, ZoneId, ZoneOffset) Method

Definition

Obtains an instance of ZonedDateTime from a local date-time using the preferred offset if possible.

[Android.Runtime.Register("ofLocal", "(Ljava/time/LocalDateTime;Ljava/time/ZoneId;Ljava/time/ZoneOffset;)Ljava/time/ZonedDateTime;", "", ApiSince=26)]
public static Java.Time.ZonedDateTime? OfLocal(Java.Time.LocalDateTime? localDateTime, Java.Time.ZoneId? zone, Java.Time.ZoneOffset? preferredOffset);
[<Android.Runtime.Register("ofLocal", "(Ljava/time/LocalDateTime;Ljava/time/ZoneId;Ljava/time/ZoneOffset;)Ljava/time/ZonedDateTime;", "", ApiSince=26)>]
static member OfLocal : Java.Time.LocalDateTime * Java.Time.ZoneId * Java.Time.ZoneOffset -> Java.Time.ZonedDateTime

Parameters

localDateTime
LocalDateTime

the local date-time, not null

zone
ZoneId

the time-zone, not null

preferredOffset
ZoneOffset

the zone offset, null if no preference

Returns

the zoned date-time, not null

Attributes

Remarks

Obtains an instance of ZonedDateTime from a local date-time using the preferred offset if possible. The local date-time is resolved to a single instant on the time-line. This is achieved by finding a valid offset from UTC/Greenwich for the local date-time as defined by the rules of the zone ID. In most cases, there is only one valid offset for a local date-time. In the case of an overlap, where clocks are set back, there are two valid offsets. If the preferred offset is one of the valid offsets then it is used. Otherwise the earlier valid offset is used, typically corresponding to "summer". In the case of a gap, where clocks jump forward, there is no valid offset. Instead, the local date-time is adjusted to be later by the length of the gap. For a typical one hour daylight savings change, the local date-time will be moved one hour later into the offset typically corresponding to "summer".

Java reference for java.time.ZonedDateTime.ofLocal.

Applies to