Språk

OffsetTime.WithOffsetSameInstant(ZoneOffset) Method

Definition

Returns a copy of this OffsetTime with the specified offset, adjusting the local time by the offset difference.

[Android.Runtime.Register("withOffsetSameInstant", "(Ljava/time/ZoneOffset;)Ljava/time/OffsetTime;", "", ApiSince=26)]
public Java.Time.OffsetTime? WithOffsetSameInstant(Java.Time.ZoneOffset? offset);
[<Android.Runtime.Register("withOffsetSameInstant", "(Ljava/time/ZoneOffset;)Ljava/time/OffsetTime;", "", ApiSince=26)>]
member this.WithOffsetSameInstant : Java.Time.ZoneOffset -> Java.Time.OffsetTime

Parameters

offset
ZoneOffset

the zone offset to change to, not null

Returns

an OffsetTime based on this time with the requested offset, not null

Attributes

Remarks

Returns a copy of this OffsetTime with the specified offset and a LocalTime adjusted by the difference between the two offsets. The time wraps around midnight. If the adjustment crosses midnight, a date combined with the result must also be adjusted to represent the same instant. This is useful for finding the local time in a different offset. For example, if this time represents 10:30+02:00 and the offset specified is +03:00, then this method will return 11:30+03:00. To change the offset without adjusting the local time use withOffsetSameLocal(java.time.ZoneOffset). This instance is immutable and unaffected by this method call.

Java reference for java.time.OffsetTime.withOffsetSameInstant.

Applies to