Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#inhmethods)

# ZoneOffsetTransition


`
public

final

class
ZoneOffsetTransition
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/java/lang/Comparable<https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition>,

https://developer.android.com/reference/java/io/Serializable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.time.zone.ZoneOffsetTransition |

<br />

*** ** * ** ***

A transition between two offsets caused by a discontinuity in the local time-line.


A transition between two offsets is normally the result of a daylight savings cutover.
The discontinuity is normally a gap in spring and an overlap in autumn.
`ZoneOffsetTransition` models the transition between the two offsets.


Gaps occur where there are local date-times that simply do not exist.
An example would be when the offset changes from `+03:00` to `+04:00`.
This might be described as 'the clocks will move forward one hour tonight at 1am'.


Overlaps occur where there are local date-times that exist twice.
An example would be when the offset changes from `+04:00` to `+03:00`.
This might be described as 'the clocks will move back one hour tonight at 2am'.

## Summary

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#compareTo(java.time.zone.ZoneOffsetTransition)(https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition otherTransition) ` Compares this transition to another based on the transition instant. |
| ` boolean` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object other) ` Checks if this object equals another. |
| ` https://developer.android.com/reference/java/time/LocalDateTime` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#getDateTimeAfter()() ` Gets the local transition date-time, as would be expressed with the 'after' offset. |
| ` https://developer.android.com/reference/java/time/LocalDateTime` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#getDateTimeBefore()() ` Gets the local transition date-time, as would be expressed with the 'before' offset. |
| ` https://developer.android.com/reference/java/time/Duration` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#getDuration()() ` Gets the duration of the transition. |
| ` https://developer.android.com/reference/java/time/Instant` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#getInstant()() ` Gets the transition instant. |
| ` https://developer.android.com/reference/java/time/ZoneOffset` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#getOffsetAfter()() ` Gets the offset after the transition. |
| ` https://developer.android.com/reference/java/time/ZoneOffset` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#getOffsetBefore()() ` Gets the offset before the transition. |
| ` int` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#hashCode()() ` Returns a suitable hash code. |
| ` boolean` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#isGap()() ` Does this transition represent a gap in the local time-line. |
| ` boolean` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#isOverlap()() ` Does this transition represent an overlap in the local time-line. |
| ` boolean` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#isValidOffset(java.time.ZoneOffset)(https://developer.android.com/reference/java/time/ZoneOffset offset) ` Checks if the specified offset is valid during this transition. |
| ` static https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#of(java.time.LocalDateTime,%20java.time.ZoneOffset,%20java.time.ZoneOffset)(https://developer.android.com/reference/java/time/LocalDateTime transition, https://developer.android.com/reference/java/time/ZoneOffset offsetBefore, https://developer.android.com/reference/java/time/ZoneOffset offsetAfter) ` Obtains an instance defining a transition between two offsets. |
| ` long` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#toEpochSecond()() ` Gets the transition instant as an epoch second. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#toString()() ` Returns a string describing this object. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/java/lang/Comparable ` |---|---| | ` abstract int` | ` https://developer.android.com/reference/java/lang/Comparable#compareTo(T)(https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition o) ` Compares this object with the specified object for order. | ||

## Public methods

### compareTo

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int compareTo (ZoneOffsetTransition otherTransition)
```

Compares this transition to another based on the transition instant.


This compares the instants of each transition.
The offsets are ignored, making this order inconsistent with equals.

<br />

| Parameters ||
|---|---|
| `otherTransition` | `ZoneOffsetTransition`: the transition to compare to, not null <br /> |

| Returns ||
|---|---|
| `int` | the comparator value, that is the comparison of this transition instant with `otherTransition` instant <br /> |

### equals

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object other)
```

Checks if this object equals another.


The entire state of the object is compared.

<br />

| Parameters ||
|---|---|
| `other` | `Object`: the other object to compare to, null returns false <br /> |

| Returns ||
|---|---|
| `boolean` | true if equal <br /> |

### getDateTimeAfter

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public LocalDateTime getDateTimeAfter ()
```

Gets the local transition date-time, as would be expressed with the 'after' offset.


This is the first date-time after the discontinuity, when the new offset applies.


The combination of the 'before' date-time and offset represents the same instant
as the 'after' date-time and offset.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/time/LocalDateTime` | the transition date-time expressed with the after offset, not null <br /> |

### getDateTimeBefore

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public LocalDateTime getDateTimeBefore ()
```

Gets the local transition date-time, as would be expressed with the 'before' offset.


This is the date-time where the discontinuity begins expressed with the 'before' offset.
At this instant, the 'after' offset is actually used, therefore the combination of this
date-time and the 'before' offset will never occur.


The combination of the 'before' date-time and offset represents the same instant
as the 'after' date-time and offset.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/time/LocalDateTime` | the transition date-time expressed with the before offset, not null <br /> |

### getDuration

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Duration getDuration ()
```

Gets the duration of the transition.


In most cases, the transition duration is one hour, however this is not always the case.
The duration will be positive for a gap and negative for an overlap.
Time-zones are second-based, so the nanosecond part of the duration will be zero.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/time/Duration` | the duration of the transition, positive for gaps, negative for overlaps <br /> |

### getInstant

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Instant getInstant ()
```

Gets the transition instant.


This is the instant of the discontinuity, which is defined as the first
instant that the 'after' offset applies.


The methods `https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#getInstant()`, `https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#getDateTimeBefore()` and `https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition#getDateTimeAfter()`
all represent the same instant.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/time/Instant` | the transition instant, not null <br /> |

### getOffsetAfter

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ZoneOffset getOffsetAfter ()
```

Gets the offset after the transition.


This is the offset in use on and after the instant of the transition.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/time/ZoneOffset` | the offset after the transition, not null <br /> |

### getOffsetBefore

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ZoneOffset getOffsetBefore ()
```

Gets the offset before the transition.


This is the offset in use before the instant of the transition.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/time/ZoneOffset` | the offset before the transition, not null <br /> |

### hashCode

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns a suitable hash code.

<br />

| Returns ||
|---|---|
| `int` | the hash code <br /> |

### isGap

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isGap ()
```

Does this transition represent a gap in the local time-line.


Gaps occur where there are local date-times that simply do not exist.
An example would be when the offset changes from `+01:00` to `+02:00`.
This might be described as 'the clocks will move forward one hour tonight at 1am'.

<br />

| Returns ||
|---|---|
| `boolean` | true if this transition is a gap, false if it is an overlap <br /> |

### isOverlap

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isOverlap ()
```

Does this transition represent an overlap in the local time-line.


Overlaps occur where there are local date-times that exist twice.
An example would be when the offset changes from `+02:00` to `+01:00`.
This might be described as 'the clocks will move back one hour tonight at 2am'.

<br />

| Returns ||
|---|---|
| `boolean` | true if this transition is an overlap, false if it is a gap <br /> |

### isValidOffset

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isValidOffset (ZoneOffset offset)
```

Checks if the specified offset is valid during this transition.


This checks to see if the given offset will be valid at some point in the transition.
A gap will always return false.
An overlap will return true if the offset is either the before or after offset.

<br />

| Parameters ||
|---|---|
| `offset` | `ZoneOffset`: the offset to check, null returns false <br /> |

| Returns ||
|---|---|
| `boolean` | true if the offset is valid during the transition <br /> |

### of

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static ZoneOffsetTransition of (LocalDateTime transition, 
                ZoneOffset offsetBefore, 
                ZoneOffset offsetAfter)
```

Obtains an instance defining a transition between two offsets.


Applications should normally obtain an instance from `https://developer.android.com/reference/java/time/zone/ZoneRules`.
This factory is only intended for use when creating `https://developer.android.com/reference/java/time/zone/ZoneRules`.

<br />

| Parameters ||
|---|---|
| `transition` | `LocalDateTime`: the transition date-time at the transition, which never actually occurs, expressed local to the before offset, not null <br /> |
| `offsetBefore` | `ZoneOffset`: the offset before the transition, not null <br /> |
| `offsetAfter` | `ZoneOffset`: the offset at and after the transition, not null <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/time/zone/ZoneOffsetTransition` | the transition, not null <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `offsetBefore` and `offsetAfter` are equal, or `transition.getNano()` returns non-zero value |

### toEpochSecond

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long toEpochSecond ()
```

Gets the transition instant as an epoch second.

<br />

| Returns ||
|---|---|
| `long` | the transition epoch second <br /> |

### toString

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string describing this object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string for debugging, not null <br /> |