ZoneOffset
Extends:
Static properties of Class LocalDate
ZoneOffset.MAX_SECONDS = 18 * LocalTime.SECONDS_PER_HOUR;
ZoneOffset.UTC = ZoneOffset.ofTotalSeconds(0);
ZoneOffset.MIN = ZoneOffset.ofTotalSeconds(-ZoneOffset.MAX_SECONDS);
ZoneOffset.MAX = ZoneOffset.ofTotalSeconds(ZoneOffset.MAX_SECONDS);
Static Method Summary
Static Public Methods | ||
public static |
of(offsetId: string): ZoneOffset Obtains an instance of ZoneOffset using the ID. |
|
public static |
ofHours(hours: number): ZoneOffset |
|
public static |
ofHoursMinutes(hours: number, minutes: number): ZoneOffset |
|
public static |
ofHoursMinutesSeconds(hours: number, minutes: number, seconds: number): ZoneOffset |
|
public static |
ofTotalMinutes(totalMinutes: number): ZoneOffset |
|
public static |
ofTotalSeconds(totalSeconds: number): ZoneOffset |
Method Summary
Public Methods | ||
public |
adjustInto(temporal: Temporal): Temporal Adjusts the specified temporal object to have the same offset as this object. |
|
public |
compareTo(other: ZoneOffset): number Compares this offset to another offset in descending order. |
|
public |
equals(obj: *): boolean Checks if this offset is equal to another offset. |
|
public |
get(field: TemporalField): number Gets the value of the specified field from this offset as an |
|
public |
getLong(field: TemporalField): number Gets the value of the specified field from this offset as a |
|
public |
hashCode(): number |
|
public |
id(): string |
|
public |
query(query: TemporalQuery): * Queries this offset using the specified query. |
|
public |
Gets the associated time-zone rules. |
|
public |
toString(): string |
|
public |
totalSeconds(): number |
Inherited Summary
From class ZoneId | ||
public static |
from(temporal: TemporalAccessor): ZoneId Obtains an instance of ZoneId from a temporal object. |
|
public static |
getAvailableZoneIds(): string[] Gets the set of available zone IDs. |
|
public static |
Obtains an instance of ZoneId from an ID ensuring that the ID is valid and available for use. |
|
public static |
ofOffset(prefix: string, offset: ZoneOffset): ZoneId Obtains an instance of ZoneId wrapping an offset. |
|
public static |
Gets the system default time-zone. |
|
public |
equals(other: *): boolean Checks if this time-zone ID is equal to another time-zone ID. |
|
public |
hashCode(): number A hash code for this time-zone ID. |
|
public |
id(): String Gets the unique time-zone ID. |
|
public |
normalized(): ZoneId Normalizes the time-zone ID, returning a ZoneOffset where possible. |
|
public |
Gets the time-zone rules for this ID allowing calculations to be performed. |
|
public |
toJSON(): string toJSON() use by JSON.stringify delegates to toString() |
|
public |
toString(): string Outputs this zone as a string, using the ID. |
Static Public Methods
public static of(offsetId: string): ZoneOffset source
Obtains an instance of ZoneOffset using the ID.
This method parses the string ID of a ZoneOffset to return an instance. The parsing accepts all the formats generated by getId, plus some additional formats:
- Z - for UTC
+h
+hh
+hh:mm
-hh:mm
+hhmm
-hhmm
+hh:mm:ss
-hh:mm:ss
+hhmmss
-hhmmss
Note that ± means either the plus or minus symbol.
The ID of the returned offset will be normalized to one of the formats described by getId.
The maximum supported range is from +18:00 to -18:00 inclusive.
Override:
ZoneId#ofParams:
Name | Type | Attribute | Description |
offsetId | string | the offset ID, not null |
Throw:
* |
DateTimeException if the offset ID is invalid |
public static ofHours(hours: number): ZoneOffset source
Params:
Name | Type | Attribute | Description |
hours | number |
public static ofHoursMinutes(hours: number, minutes: number): ZoneOffset source
Params:
Name | Type | Attribute | Description |
hours | number | ||
minutes | number |
public static ofHoursMinutesSeconds(hours: number, minutes: number, seconds: number): ZoneOffset source
Params:
Name | Type | Attribute | Description |
hours | number | ||
minutes | number | ||
seconds | number |
public static ofTotalMinutes(totalMinutes: number): ZoneOffset source
Params:
Name | Type | Attribute | Description |
totalMinutes | number |
public static ofTotalSeconds(totalSeconds: number): ZoneOffset source
Params:
Name | Type | Attribute | Description |
totalSeconds | number |
Public Methods
public adjustInto(temporal: Temporal): Temporal source
Adjusts the specified temporal object to have the same offset as this object.
This returns a temporal object of the same observable type as the input with the offset changed to be the same as this.
The adjustment is equivalent to using Temporal#with passing ChronoField#OFFSET_SECONDS as the field.
In most cases, it is clearer to reverse the calling pattern by using Temporal#with:
// these two lines are equivalent, but the second approach is recommended temporal = thisOffset.adjustInto(temporal); temporal = temporal.with(thisOffset);
This instance is immutable and unaffected by this method call.
Params:
Name | Type | Attribute | Description |
temporal | Temporal | the target object to be adjusted, not null |
Throw:
* |
DateTimeException if unable to make the adjustment |
* |
ArithmeticException if numeric overflow occurs |
public compareTo(other: ZoneOffset): number source
Compares this offset to another offset in descending order.
The offsets are compared in the order that they occur for the same time
of day around the world. Thus, an offset of +10:00
comes before an
offset of +09:00
and so on down to -18:00
.
The comparison is "consistent with equals", as defined by Comparable.
Params:
Name | Type | Attribute | Description |
other | ZoneOffset |
|
the other date to compare to, not null |
Return:
number | the comparator value, negative if less, positive if greater |
Throw:
* |
NullPointerException if other is null |
public equals(obj: *): boolean source
Checks if this offset is equal to another offset.
The comparison is based on the amount of the offset in seconds. This is equivalent to a comparison by ID.
Override:
ZoneId#equalsParams:
Name | Type | Attribute | Description |
obj | * | the object to check, null returns false |
Return:
boolean | true if this is equal to the other offset |
public get(field: TemporalField): number source
Gets the value of the specified field from this offset as an int
.
This queries this offset for the value for the specified field. The returned value will always be within the valid range of values for the field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown.
If the field is a ChronoField then the query is implemented here. The OFFSET_SECONDS field returns the value of the offset. All other ChronoField instances will throw a DateTimeException.
If the field is not a ChronoField, then the result of this method
is obtained by invoking TemporalField.getFrom
passing this
as the argument. Whether the value can be obtained,
and what the value represents, is determined by the field.
Params:
Name | Type | Attribute | Description |
field | TemporalField | the field to get, not null |
Return:
number | the value for the field |
Throw:
* |
DateTimeException if a value for the field cannot be obtained |
* |
ArithmeticException if numeric overflow occurs |
public getLong(field: TemporalField): number source
Gets the value of the specified field from this offset as a long
.
This queries this offset for the value for the specified field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown.
If the field is a ChronoField then the query is implemented here. The OFFSET_SECONDS field returns the value of the offset. All other ChronoField instances will throw a DateTimeException.
If the field is not a ChronoField, then the result of this method
is obtained by invoking TemporalField.getFrom
passing this
as the argument. Whether the value can be obtained,
and what the value represents, is determined by the field.
Params:
Name | Type | Attribute | Description |
field | TemporalField | the field to get, not null |
Return:
number | the value for the field |
Throw:
* |
DateTimeException if a value for the field cannot be obtained |
* |
ArithmeticException if numeric overflow occurs |
public hashCode(): number source
A hash code for this time-zone ID.
Override:
ZoneId#hashCodeReturn:
number |
public id(): string source
Gets the unique time-zone ID.
This ID uniquely defines this object. The format of an offset based ID is defined by ZoneOffset#getId.
Override:
ZoneId#idReturn:
string |
public query(query: TemporalQuery): * source
Queries this offset using the specified query.
This queries this offset using the specified query strategy object. The TemporalQuery object defines the logic to be used to obtain the result. Read the documentation of the query to understand what the result of this method will be.
The result of this method is obtained by invoking the
TemporalQuery#queryFrom method on the
specified query passing this
as the argument.
Params:
Name | Type | Attribute | Description |
query | TemporalQuery | the query to invoke, not null |
Return:
* | the query result, null may be returned (defined by the query) |
Throw:
* |
DateTimeException if unable to query (defined by the query) |
* |
ArithmeticException if numeric overflow occurs (defined by the query) |
public rules(): ZoneRules source
Gets the associated time-zone rules.
The rules will always return this offset when queried. The implementation class is immutable, thread-safe and serializable.
Override:
ZoneId#rulespublic toString(): string source
Outputs this zone as a string, using the ID.
Override:
ZoneId#toStringReturn:
string |