# ZoneOffsetTransition

public final class **ZoneOffsetTransition** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)\<[ZoneOffsetTransition](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneOffsetTransition.html)\> [Serializable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Serializable.html) 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'.

### Public Method Summary

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

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.lang.Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)

|---|---|
| abstract int | [compareTo](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html#compareTo(T))([ZoneOffsetTransition](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneOffsetTransition.html) o) Compares this object with the specified object for order. |

## Public Methods

#### public int
**compareTo**
([ZoneOffsetTransition](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneOffsetTransition.html) transition)

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.

##### Parameters

| transition | the transition to compare to, not null |
|---|---|

##### Returns

- the comparator value, negative if less, positive if greater

#### public boolean
**equals**
([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) other)

Checks if this object equals another.


The entire state of the object is compared.

##### Parameters

| other | the other object to compare to, null returns false |
|---|---|

##### Returns

- true if equal

#### public [LocalDateTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/LocalDateTime.html)
**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.

##### Returns

- the transition date-time expressed with the after offset, not null

#### public [LocalDateTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/LocalDateTime.html)
**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.

##### Returns

- the transition date-time expressed with the before offset, not null

#### public [Duration](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/Duration.html)
**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.

##### Returns

- the duration of the transition, positive for gaps, negative for overlaps

#### public [Instant](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/Instant.html)
**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://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneOffsetTransition.html#getInstant()`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneOffsetTransition.html#getDateTimeBefore()` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneOffsetTransition.html#getDateTimeAfter()`
all represent the same instant.

##### Returns

- the transition instant, not null

#### public [ZoneOffset](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/ZoneOffset.html)
**getOffsetAfter**
()

Gets the offset after the transition.


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

##### Returns

- the offset after the transition, not null

#### public [ZoneOffset](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/ZoneOffset.html)
**getOffsetBefore**
()

Gets the offset before the transition.


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

##### Returns

- the offset before the transition, not null

#### public int
**hashCode**
()

Returns a suitable hash code.

##### Returns

- the hash code

#### 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'.

##### Returns

- true if this transition is a gap, false if it is an overlap

#### 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'.

##### Returns

- true if this transition is an overlap, false if it is a gap

#### public boolean
**isValidOffset**
([ZoneOffset](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/ZoneOffset.html) 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.

##### Parameters

| offset | the offset to check, null returns false |
|---|---|

##### Returns

- true if the offset is valid during the transition

#### public static [ZoneOffsetTransition](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneOffsetTransition.html)
**of**
([LocalDateTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/LocalDateTime.html) transition, [ZoneOffset](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/ZoneOffset.html) offsetBefore, [ZoneOffset](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/ZoneOffset.html) offsetAfter)

Obtains an instance defining a transition between two offsets.


Applications should normally obtain an instance from `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneRules.html`.
This factory is only intended for use when creating `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/zone/ZoneRules.html`.

##### Parameters

| transition | the transition date-time at the transition, which never actually occurs, expressed local to the before offset, not null |
| offsetBefore | the offset before the transition, not null |
| offsetAfter | the offset at and after the transition, not null |
|---|---|

##### Returns

- the transition, not null

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `offsetBefore` and `offsetAfter` are equal, or `transition.getNano()` returns non-zero value |
|---|---|

#### public long
**toEpochSecond**
()

Gets the transition instant as an epoch second.

##### Returns

- the transition epoch second

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Returns a string describing this object.

##### Returns

- a string for debugging, not null