Home Reference Source
public class | source

ChronoZonedDateTime

Extends:

TemporalAccessorTemporal → ChronoZonedDateTime

Direct Subclass:

ZonedDateTime

Method Summary

Public Methods
public

compareTo(other: ChronoZonedDateTime): number

Compares this date-time to another date-time, including the chronology.

public

equals(other: *): boolean

Checks if this date-time is equal to another date-time.

public

format(formatter: DateTimeFormatter): string

Outputs this date-time as a string using the formatter.

public

isAfter(other: ChronoZonedDateTime): boolean

Checks if the instant of this date-time is after that of the specified date-time.

public

isBefore(other: ChronoZonedDateTime): boolean

Checks if the instant of this date-time is before that of the specified date-time.

public

isEqual(other: ChronoZonedDateTime): boolean

Checks if the instant of this date-time is equal to that of the specified date-time.

public

query(query: *): *

public

toEpochSecond(): number

Converts this date-time to the number of seconds from the epoch of 1970-01-01T00:00:00Z.

public

Converts this date-time to an Instant.

Inherited Summary

From class TemporalAccessor
public

get(field: TemporalField): number

Gets the value of the specified field as an int.

public

getLong(field: *)

public

isSupported(field: *)

public

query(query: TemporalQuery): *

Queries this date-time.

public

Gets the range of valid values for the specified field.

From class Temporal
public

isSupported(fieldOrUnit: TemporalUnit): boolean

Checks if the specified unit is supported.

public

minus(amount: TemporalAmount | number, unit: TemporalUnit): Temporal

function overloading for Temporal.plus

public

plus(amount: TemporalAmount | number, unit: TemporalUnit): Temporal

function overloading for Temporal.plus

public

until(endTemporal: Temporal, unit: TemporalUnit): number

Calculates the period between this temporal and another temporal in terms of the specified unit.

public

with(adjusterOrField: TemporalAdjuster | TemporalField, newValue: number): Temporal

function overloading for Temporal.with

Public Methods

public compareTo(other: ChronoZonedDateTime): number source

Compares this date-time to another date-time, including the chronology.

The comparison is based first on the instant, then on the local date-time, then on the zone ID, then on the chronology. It is "consistent with equals", as defined by Comparable.

If all the date-time objects being compared are in the same chronology, then the additional chronology stage is not required.

Params:

NameTypeAttributeDescription
other ChronoZonedDateTime

the other date-time to compare to, not null

Return:

number

the comparator value, negative if less, positive if greater

public equals(other: *): boolean source

Checks if this date-time is equal to another date-time.

The comparison is based on the offset date-time and the zone. To compare for the same instant on the time-line, use compareTo. Only objects of type ChronoZoneDateTime are compared, other types return false.

Params:

NameTypeAttributeDescription
other *

the object to check, null returns false

Return:

boolean

true if this is equal to the other date-time

public format(formatter: DateTimeFormatter): string source

Outputs this date-time as a string using the formatter.

Params:

NameTypeAttributeDescription
formatter DateTimeFormatter

the formatter to use, not null

Return:

string

the formatted date-time string, not null

Throw:

*

DateTimeException if an error occurs during printing

public isAfter(other: ChronoZonedDateTime): boolean source

Checks if the instant of this date-time is after that of the specified date-time.

This method differs from the comparison in compareTo in that it only compares the instant of the date-time. This is equivalent to using dateTime1.toInstant().isAfter(dateTime2.toInstant()).

Params:

NameTypeAttributeDescription
other ChronoZonedDateTime
  • nullable: false

the other date-time to compare to, not null

Return:

boolean

true if this is after the specified date-time

public isBefore(other: ChronoZonedDateTime): boolean source

Checks if the instant of this date-time is before that of the specified date-time.

This method differs from the comparison in compareTo in that it only compares the instant of the date-time. This is equivalent to using dateTime1.toInstant().isBefore(dateTime2.toInstant()).

Params:

NameTypeAttributeDescription
other ChronoZonedDateTime
  • nullable: false

the other date-time to compare to, not null

Return:

boolean

true if this point is before the specified date-time

public isEqual(other: ChronoZonedDateTime): boolean source

Checks if the instant of this date-time is equal to that of the specified date-time.

This method differs from the comparison in compareTo and equals in that it only compares the instant of the date-time. This is equivalent to using dateTime1.toInstant().equals(dateTime2.toInstant()).

Params:

NameTypeAttributeDescription
other ChronoZonedDateTime
  • nullable: false

the other date-time to compare to, not null

Return:

boolean

true if the instant equals the instant of the specified date-time

public query(query: *): * source

Queries this date-time.

This queries this date-time using the specified query strategy object.

Queries are a key tool for extracting information from date-times. They exists to externalize the process of querying, permitting different approaches, as per the strategy design pattern. Examples might be a query that checks if the date is the day before February 29th in a leap year, or calculates the number of days to your next birthday.

The most common query implementations are method references, such as LocalDate::from and ZoneId::from. Further implementations are on TemporalQueries. Queries may also be defined by applications.

Override:

TemporalAccessor#query

Params:

NameTypeAttributeDescription
query *

Return:

*

public toEpochSecond(): number source

Converts this date-time to the number of seconds from the epoch of 1970-01-01T00:00:00Z.

This uses the local date-time (see toLocalDateTime) and offset (see getOffset) to calculate the epoch-second value, which is the number of elapsed seconds from 1970-01-01T00:00:00Z. Instants on the time-line after the epoch are positive, earlier are negative.

Return:

number

the number of seconds from the epoch of 1970-01-01T00:00:00Z

public toInstant(): Instant source

Converts this date-time to an Instant.

This returns an Instant representing the same point on the time-line as this date-time. The calculation combines the local date-time (see toLocalDateTime) and offset (see getOffset).

Return:

Instant

an Instant representing the same instant, not null