Home Reference Source Repository
import {ChronoZonedDateTime} from 'js-joda/src/chrono/ChronoZonedDateTime.js'
public class | source

ChronoZonedDateTime

Extends:

TemporalAccessorTemporal → ChronoZonedDateTime

Direct Subclass:

ZonedDateTime

Method Summary

Public Methods
public

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

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

public

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

public

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

public

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

public

query(query: *): *

public

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

Gets the value of the specified field as an int.

public

query(query: TemporalQuery): *

Queries this date-time.

public

Gets the range of valid values for the specified field.

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

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