ZoneRules.GetOffset Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| GetOffset(Instant) |
Gets the offset applicable at the specified instant in these rules. |
| GetOffset(LocalDateTime) |
Gets a suitable offset for the specified local date-time in these rules. |
GetOffset(Instant)
Gets the offset applicable at the specified instant in these rules.
[Android.Runtime.Register("getOffset", "(Ljava/time/Instant;)Ljava/time/ZoneOffset;", "", ApiSince=26)]
public Java.Time.ZoneOffset? GetOffset(Java.Time.Instant? instant);
[<Android.Runtime.Register("getOffset", "(Ljava/time/Instant;)Ljava/time/ZoneOffset;", "", ApiSince=26)>]
member this.GetOffset : Java.Time.Instant -> Java.Time.ZoneOffset
Parameters
- instant
- Instant
The instant to find the offset for. Fixed-offset rules may ignore null; variable rules do not.
Returns
The offset applicable at the specified instant.
- Attributes
Exceptions
Thrown if instant is null and the rules are not fixed-offset.
Remarks
Gets the offset applicable at the specified instant in these rules. The mapping from an instant to an offset is simple, there is only one valid offset for each instant. This method returns that offset.
Java reference for java.time.zone.ZoneRules.getOffset.
Applies to
GetOffset(LocalDateTime)
Gets a suitable offset for the specified local date-time in these rules.
[Android.Runtime.Register("getOffset", "(Ljava/time/LocalDateTime;)Ljava/time/ZoneOffset;", "", ApiSince=26)]
public Java.Time.ZoneOffset? GetOffset(Java.Time.LocalDateTime? localDateTime);
[<Android.Runtime.Register("getOffset", "(Ljava/time/LocalDateTime;)Ljava/time/ZoneOffset;", "", ApiSince=26)>]
member this.GetOffset : Java.Time.LocalDateTime -> Java.Time.ZoneOffset
Parameters
- localDateTime
- LocalDateTime
The local date-time to query. Fixed-offset rules may ignore null; variable rules do not.
Returns
The best available offset for the local date-time; for a gap or overlap, the offset before the transition.
- Attributes
Exceptions
Thrown if localDateTime is null and the rules are not fixed-offset.
Remarks
Gets a suitable offset for the specified local date-time in these rules. The mapping from a local date-time to an offset is not straightforward. There are three cases: Normal, with one valid offset. For the vast majority of the year, the normal case applies, where there is a single valid offset for the local date-time; Gap, with zero valid offsets. This is when clocks jump forward typically due to the spring daylight savings change from "winter" to "summer". In a gap there are local date-time values with no valid offset; Overlap, with two valid offsets. This is when clocks are set back typically due to the autumn daylight savings change from "summer" to "winter". In an overlap there are local date-time values with two valid offsets. Thus, for any given local date-time there can be zero, one or two valid offsets. This method returns the single offset in the Normal case, and in the Gap or Overlap case it returns the offset before the transition. Since, in the case of Gap and Overlap, the offset returned is a "best" value, rather than the "correct" value, it should be treated with care. Applications that care about the correct offset should use a combination of this method, getValidOffsets(LocalDateTime) and getTransition(LocalDateTime).
Java reference for java.time.zone.ZoneRules.getOffset.