Home Reference Source
public class | source

SystemDefaultZoneRules

Extends:

ZoneRules → SystemDefaultZoneRules

Method Summary

Public Methods
public
public

equals(other: *): boolean

public
public

isFixedOffset(): boolean

public

isValidOffset(dateTime: LocalDateTime, offset: ZoneOffset): boolean

public
public

offsetOfEpochMilli(epochMilli: number): ZoneOffset

public
public

This implementation is NOT returning the best value in a gap or overlap situation as specified at ZoneRules.offsetOfLocalDateTime.

public
public

standardOffset(instant: *): ZoneOffset

public

toString(): string

public

transition(): *

public
public
public

validOffsets(localDateTime: *): ZoneOffset[]

Inherited Summary

From class ZoneRules
public static

of(offset: ZoneOffset): ZoneRules

Obtains an instance of ZoneRules that always uses the same offset.

public

Gets the amount of daylight savings in use for the specified instant in this zone.

public

isDaylightSavings(instant: Instant): boolean

Checks if the specified instant is in daylight savings.

public

isFixedOffset(): boolean

Checks of the zone rules are fixed, such that the offset never varies.

public

isValidOffset(localDateTime: LocalDateTime, offset: ZoneOffset): boolean

Checks if the offset date-time is valid for these rules.

public

Gets the next transition after the specified instant.

public

offset(instantOrLocalDateTime: *): ZoneOffset

public

offsetOfEpochMilli(epochMilli: number): ZoneOffset

Gets the offset applicable at the specified epochMilli in these rules.

public

Gets the offset applicable at the specified instant in these rules.

public

Gets a suitable offset for the specified local date-time in these rules.

public

Gets the previous transition before the specified instant.

public

Gets the standard offset for the specified instant in this zone.

public

toJSON(): string

toJSON() use by JSON.stringify delegates to toString()

public
public

Gets the offset transition applicable at the specified local date-time in these rules.

public

transitionRules(): ZoneOffsetTransitionRule[]

Gets the list of transition rules for years beyond those defined in the transition list.

public

Gets the complete list of fully defined transitions.

public

Gets the offset applicable at the specified local date-time in these rules.

Public Methods

public daylightSavings() source

Gets the amount of daylight savings in use for the specified instant in this zone.

This provides access to historic information on how the amount of daylight savings has changed over time. This is the difference between the standard offset and the actual offset. Typically the amount is zero during winter and one hour during summer. Time-zones are second-based, so the nanosecond part of the duration will be zero.

Override:

ZoneRules#daylightSavings

Throw:

*

DateTimeException not supported

public equals(other: *): boolean source

Params:

NameTypeAttributeDescription
other *

Return:

boolean

public isDaylightSavings() source

Checks if the specified instant is in daylight savings.

This checks if the standard and actual offsets are the same at the specified instant.

Override:

ZoneRules#isDaylightSavings

Throw:

*

DateTimeException not supported

public isFixedOffset(): boolean source

Checks of the zone rules are fixed, such that the offset never varies.

Override:

ZoneRules#isFixedOffset

Return:

boolean

public isValidOffset(dateTime: LocalDateTime, offset: ZoneOffset): boolean source

Checks if the offset date-time is valid for these rules.

To be valid, the local date-time must not be in a gap and the offset must match the valid offsets.

Override:

ZoneRules#isValidOffset

Params:

NameTypeAttributeDescription
dateTime LocalDateTime
offset ZoneOffset

Return:

boolean

public nextTransition() source

Gets the next transition after the specified instant.

This returns details of the next transition after the specified instant. For example, if the instant represents a point where "Summer" daylight savings time applies, then the method will return the transition to the next "Winter" time.

Override:

ZoneRules#nextTransition

Throw:

*

DateTimeException not supported

public offsetOfEpochMilli(epochMilli: number): ZoneOffset source

Gets the offset applicable at the specified epochMilli in these rules.

The method is for javascript performance optimisation.

Override:

ZoneRules#offsetOfEpochMilli

Params:

NameTypeAttributeDescription
epochMilli number

Return:

ZoneOffset

public offsetOfInstant(instant: Instant): ZoneOffset source

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.

Override:

ZoneRules#offsetOfInstant

Params:

NameTypeAttributeDescription
instant Instant

Return:

ZoneOffset

public offsetOfLocalDateTime(localDateTime: LocalDateTime): ZoneOffset source

This implementation is NOT returning the best value in a gap or overlap situation as specified at ZoneRules.offsetOfLocalDateTime.

The calculated offset depends Date.prototype.getTimezoneOffset and its not specified at the ECMA-262 specification how to handle daylight savings gaps/ overlaps.

The Chrome Browser version 49 is returning the next transition offset in a gap/overlap situation, other browsers/ engines might do it in the same way.

Override:

ZoneRules#offsetOfLocalDateTime

Params:

NameTypeAttributeDescription
localDateTime LocalDateTime

Return:

ZoneOffset

public previousTransition() source

Gets the previous transition before the specified instant.

This returns details of the previous transition after the specified instant. For example, if the instant represents a point where "summer" daylight saving time applies, then the method will return the transition from the previous "winter" time.

Override:

ZoneRules#previousTransition

Throw:

*

DateTimeException not supported

public standardOffset(instant: *): ZoneOffset source

Gets the standard offset for the specified instant in this zone.

This provides access to historic information on how the standard offset has changed over time. The standard offset is the offset before any daylight saving time is applied. This is typically the offset applicable during winter.

Override:

ZoneRules#standardOffset

Params:

NameTypeAttributeDescription
instant *

Return:

ZoneOffset

public toString(): string source

Override:

ZoneRules#toString

Return:

string

public transition(): * source

Gets the offset transition applicable at 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.

A transition is used to model the cases of a Gap or Overlap. The Normal case will return null.

There are various ways to handle the conversion from a LocalDateTime. One technique, using this method, would be:

 ZoneOffsetTransition trans = rules.getTransition(localDT);
 if (trans != null) {
   // Gap or Overlap: determine what to do from transition
 } else {
   // Normal case: only one valid offset
   zoneOffset = rule.getOffset(localDT);
 }

Override:

ZoneRules#transition

Return:

*

null, not supported

public transitionRules() source

Gets the list of transition rules for years beyond those defined in the transition list.

The complete set of transitions for this rules instance is defined by this method and getTransitions. This method returns instances of ZoneOffsetTransitionRule that define an algorithm for when transitions will occur.

For any given ZoneRules, this list contains the transition rules for years beyond those years that have been fully defined. These rules typically refer to future daylight saving time rule changes.

If the zone defines daylight savings into the future, then the list will normally be of size two and hold information about entering and exiting daylight savings. If the zone does not have daylight savings, or information about future changes is uncertain, then the list will be empty.

The list will be empty for fixed offset rules and for any time-zone where there is no daylight saving time. The list will also be empty if the transition rules are unknown.

Override:

ZoneRules#transitionRules

Throw:

*

DateTimeException not supported

public transitions() source

Gets the complete list of fully defined transitions.

The complete set of transitions for this rules instance is defined by this method and getTransitionRules. This method returns those transitions that have been fully defined. These are typically historical, but may be in the future.

The list will be empty for fixed offset rules and for any time-zone where there has only ever been a single offset. The list will also be empty if the transition rules are unknown.

Override:

ZoneRules#transitions

Throw:

*

DateTimeException not supported

public validOffsets(localDateTime: *): ZoneOffset[] source

Gets the offset applicable at 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 that list of valid offsets, which is a list of size 0, 1 or 2. In the case where there are two offsets, the earlier offset is returned at index 0 and the later offset at index 1.

There are various ways to handle the conversion from a LocalDateTime. One technique, using this method, would be:

 List<ZoneOffset> validOffsets = rules.getOffset(localDT);
 if (validOffsets.size() == 1) {
   // Normal case: only one valid offset
   zoneOffset = validOffsets.get(0);
 } else {
   // Gap or Overlap: determine what to do from transition (which will be non-null)
   ZoneOffsetTransition trans = rules.getTransition(localDT);
 }

In theory, it is possible for there to be more than two valid offsets. This would happen if clocks to be put back more than once in quick succession. This has never happened in the history of time-zones and thus has no special handling. However, if it were to happen, then the list would return more than 2 entries.

Override:

ZoneRules#validOffsets

Params:

NameTypeAttributeDescription
localDateTime *

Return:

ZoneOffset[]