core / io.islandtime / ZonedDateTime

ZonedDateTime

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) class ZonedDateTime : TimePoint<ZonedDateTime>

A date and time of day in a particular region.

ZonedDateTime takes time zone rules into account when performing calendrical calculations.

Properties

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

additionalNanosecondsSinceUnixEpoch

The number of additional nanoseconds on top of secondsSinceUnixEpoch.

val additionalNanosecondsSinceUnixEpoch: IntNanoseconds
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

date

The local date.

val date: Date
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

dateTime

The local date and time of day.

val dateTime: DateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

dayOfMonth

The day of the month.

val dayOfMonth: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

dayOfWeek

The day of the week.

val dayOfWeek: DayOfWeek
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

dayOfYear

The day of the year.

val dayOfYear: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

hour

The hour of the day.

val hour: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

instant

The Instant representing the same time point.

val instant: Instant
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

isInLeapYear

Check if this date falls within a leap year.

val isInLeapYear: Boolean
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

isLeapDay

Check if this is a leap day.

val isLeapDay: Boolean
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

lengthOfMonth

The length of this date's month in days.

val lengthOfMonth: IntDays
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

lengthOfYear

The length of this date's year in days.

val lengthOfYear: IntDays
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

millisecondsSinceUnixEpoch

The number of milliseconds since the Unix epoch of 1970-01-01T00:00Z.

val millisecondsSinceUnixEpoch: LongMilliseconds
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

minute

The minute of the hour.

val minute: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

month

The month of the year.

val month: Month
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

monthNumber

The ISO month number, from 1-12.

val monthNumber: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

nanosecond

The nanosecond of the second.

val nanosecond: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

offset

The offset from UTC.

val offset: UtcOffset
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

offsetDateTime

val offsetDateTime: OffsetDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

offsetTime

The combined time of day and offset.

val offsetTime: OffsetTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

second

The second of the minute.

val second: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

secondsSinceUnixEpoch

The number of seconds since the Unix epoch of 1970-01-01T00:00Z.

val secondsSinceUnixEpoch: LongSeconds
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

time

The local time of day.

val time: Time
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

year

The year.

val year: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

yearMonth

val yearMonth: YearMonth
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

zone

The time zone.

val zone: TimeZone

Functions

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

adjustedTo

Changes the time zone of a ZonedDateTime, adjusting the date, time, and offset such that the instant represented by it remains the same.

fun adjustedTo(newTimeZone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

copy

Returns a copy of this date-time with the values of any individual components replaced by the new values specified.

fun copy(dateTime: DateTime = this.dateTime, offset: UtcOffset = this.offset, zone: TimeZone = this.zone): ZonedDateTime
fun copy(date: Date = this.date, time: Time = this.time, offset: UtcOffset = this.offset, zone: TimeZone = this.zone): ZonedDateTime
fun copy(year: Int = this.year, dayOfYear: Int = this.dayOfYear, hour: Int = this.hour, minute: Int = this.minute, second: Int = this.second, nanosecond: Int = this.nanosecond, offset: UtcOffset = this.offset, zone: TimeZone = this.zone): ZonedDateTime
fun copy(year: Int = this.year, month: Month = this.month, dayOfMonth: Int = this.dayOfMonth, hour: Int = this.hour, minute: Int = this.minute, second: Int = this.second, nanosecond: Int = this.nanosecond, offset: UtcOffset = this.offset, zone: TimeZone = this.zone): ZonedDateTime
fun copy(year: Int = this.year, monthNumber: Int, dayOfMonth: Int = this.dayOfMonth, hour: Int = this.hour, minute: Int = this.minute, second: Int = this.second, nanosecond: Int = this.nanosecond, offset: UtcOffset = this.offset, zone: TimeZone = this.zone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

equals

fun equals(other: Any?): Boolean
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

hashCode

fun hashCode(): Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

minus

Returns this date-time with period subtracted from it.

operator fun minus(period: Period): ZonedDateTimeoperator fun minus(duration: Duration): ZonedDateTime
operator fun minus(years: IntYears): ZonedDateTime
operator fun minus(years: LongYears): ZonedDateTime
operator fun minus(months: IntMonths): ZonedDateTime
operator fun minus(months: LongMonths): ZonedDateTime
operator fun minus(weeks: IntWeeks): ZonedDateTime
operator fun minus(weeks: LongWeeks): ZonedDateTime
operator fun minus(days: IntDays): ZonedDateTime
operator fun minus(days: LongDays): ZonedDateTime
operator fun minus(hours: IntHours): ZonedDateTime
operator fun minus(hours: LongHours): ZonedDateTime
operator fun minus(minutes: IntMinutes): ZonedDateTime
operator fun minus(minutes: LongMinutes): ZonedDateTime
operator fun minus(seconds: IntSeconds): ZonedDateTime
operator fun minus(seconds: LongSeconds): ZonedDateTime
operator fun minus(milliseconds: IntMilliseconds): ZonedDateTime
operator fun minus(milliseconds: LongMilliseconds): ZonedDateTime
operator fun minus(microseconds: IntMicroseconds): ZonedDateTime
operator fun minus(microseconds: LongMicroseconds): ZonedDateTime
operator fun minus(nanoseconds: IntNanoseconds): ZonedDateTime
operator fun minus(nanoseconds: LongNanoseconds): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

plus

Returns this date-time with period added to it.

operator fun plus(period: Period): ZonedDateTimeoperator fun plus(duration: Duration): ZonedDateTime
operator fun plus(years: IntYears): ZonedDateTime
operator fun plus(years: LongYears): ZonedDateTime
operator fun plus(months: IntMonths): ZonedDateTime
operator fun plus(months: LongMonths): ZonedDateTime
operator fun plus(weeks: IntWeeks): ZonedDateTime
operator fun plus(weeks: LongWeeks): ZonedDateTime
operator fun plus(days: IntDays): ZonedDateTime
operator fun plus(days: LongDays): ZonedDateTime
operator fun plus(hours: IntHours): ZonedDateTime
operator fun plus(hours: LongHours): ZonedDateTime
operator fun plus(minutes: IntMinutes): ZonedDateTime
operator fun plus(minutes: LongMinutes): ZonedDateTime
operator fun plus(seconds: IntSeconds): ZonedDateTime
operator fun plus(seconds: LongSeconds): ZonedDateTime
operator fun plus(milliseconds: IntMilliseconds): ZonedDateTime
operator fun plus(milliseconds: LongMilliseconds): ZonedDateTime
operator fun plus(microseconds: IntMicroseconds): ZonedDateTime
operator fun plus(microseconds: LongMicroseconds): ZonedDateTime
operator fun plus(nanoseconds: IntNanoseconds): ZonedDateTime
operator fun plus(nanoseconds: LongNanoseconds): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

rangeTo

operator fun rangeTo(other: ZonedDateTime): ZonedDateTimeInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toString

Converts this date-time to a string in ISO-8601 extended format. For example, 2012-04-15T17:31:45.923452091-04:00[America/New_York] or 2020-02-13T02:30Z.

fun toString(): String
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

withEarlierOffsetAtOverlap

If the local date-time falls during an overlap caused by a daylight savings transition, a ZonedDateTime with the same local date and time will be returned, but using the earlier of the two valid offsets.

fun withEarlierOffsetAtOverlap(): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

withFixedOffsetZone

If this date-time uses a region-based time zone, a copy with a fixed offset will be returned. Otherwise, this date-time will be returned unchanged.

fun withFixedOffsetZone(): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

withLaterOffsetAtOverlap

If the local date-time falls during an overlap caused by a daylight savings transition, a ZonedDateTime with the same local date and time will be returned, but using the later of the two valid offsets.

fun withLaterOffsetAtOverlap(): ZonedDateTime

Companion Object Properties

DEFAULT_SORT_ORDER

Compares by instant, then date-time, then time zone. Using this Comparator guarantees a deterministic order when sorting.

(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) val DEFAULT_SORT_ORDER: <ERROR CLASS>
(jvm) val DEFAULT_SORT_ORDER: Comparator<ZonedDateTime>

TIMELINE_ORDER

Compares by timeline order only, ignoring any offset or time zone differences.

(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) val TIMELINE_ORDER: <ERROR CLASS>
(jvm) val TIMELINE_ORDER: Comparator<TimePoint<*>>

Companion Object Functions

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromInstant

Creates a ZonedDateTime from the instant represented by a local date-time and offset. The resulting ZonedDateTime may have a different date-time and offset depending on the time zone rules, but the instant will be the same.

fun fromInstant(dateTime: DateTime, offset: UtcOffset, zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromLocal

Creates a ZonedDateTime from a local date and time, optionally using a preferred offset. If the local date and time fall during an overlap, preferredOffset will be used if it represents one of the two valid offsets. If it is null or invalid, it will be ignored.

fun fromLocal(dateTime: DateTime, zone: TimeZone, preferredOffset: UtcOffset? = null): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromMillisecondOfUnixEpoch

Creates a ZonedDateTime from the millisecond of the Unix epoch at zone.

fun fromMillisecondOfUnixEpoch(millisecond: Long, zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromMillisecondsSinceUnixEpoch

Creates a ZonedDateTime from a duration of milliseconds relative to the Unix epoch at zone.

fun fromMillisecondsSinceUnixEpoch(milliseconds: LongMilliseconds, zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromSecondOfUnixEpoch

Creates a ZonedDateTime from the second of the Unix epoch at zone.

fun fromSecondOfUnixEpoch(second: Long, nanosecond: Int = 0, zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromSecondsSinceUnixEpoch

Creates a ZonedDateTime from a duration of seconds relative to the Unix epoch at zone, optionally, with some number of additional nanoseconds added to it.

fun fromSecondsSinceUnixEpoch(seconds: LongSeconds, nanosecondAdjustment: IntNanoseconds = 0.nanoseconds, zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromUnixEpochMillisecond

fun fromUnixEpochMillisecond(millisecond: Long, zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromUnixEpochSecond

fun fromUnixEpochSecond(second: Long, nanoOfSecond: Int, zone: TimeZone): ZonedDateTime

Extension Functions

(jvm)

endOfWeek

The date-time at the last representable instant of the week that this date-time falls in. The first day of the week will be determined by locale.

fun ZonedDateTime.endOfWeek(locale: Locale): ZonedDateTime
(jvm)

startOfWeek

The date-time at the first instant of the week that this date-time falls in. The first day of the week will be determined by locale.

fun ZonedDateTime.startOfWeek(locale: Locale): ZonedDateTime
(jvm)

toJavaZonedDateTime

Convert to an equivalent Java ZonedDateTime.

fun ZonedDateTime.toJavaZonedDateTime(): ZonedDateTime
(jvm)

week

The interval defining the week that this date-time falls within. The first day of the week will be the default associated with the provided locale.

fun ZonedDateTime.week(locale: Locale): ZonedDateTimeInterval
(jvm)

weekBasedYear

The week-based year, calculated using the week definition associated with the provided locale. This value differs from the regular ISO year when the week number falls in the preceding or following year.

fun ZonedDateTime.weekBasedYear(locale: Locale): Int
(jvm)

weekInterval

fun ZonedDateTime.weekInterval(locale: Locale): ZonedDateTimeInterval
(jvm)

weekOfMonth

The week of the month, from 0-6, calculated using the default week definition associated with the provided locale.

fun ZonedDateTime.weekOfMonth(locale: Locale): Int
(jvm)

weekOfWeekBasedYear

The week number of the week-based year, calculated using the week definition associated with the provided locale.

fun ZonedDateTime.weekOfWeekBasedYear(locale: Locale): Int
(jvm)

weekOfYear

The week of the year, calculated using the week definition associated with the provided locale. If the week number is associated with the preceding year, 0 will be returned.

fun ZonedDateTime.weekOfYear(locale: Locale): Int