ZonedDateTimeInterval

A half-open interval of zoned date-times based on timeline order.

DateTime.MIN and DateTime.MAX are used as sentinels to indicate an unbounded (ie. infinite) start or end. A ZonedDateTime with either as the date-time component will be treated accordingly, regardless of the offset or time zone.

class ZonedDateTimeInterval(start: ZonedDateTime,endExclusive: ZonedDateTime) : TimePointInterval<ZonedDateTime>

Constructors

ZonedDateTimeInterval
Link copied to clipboard
common
fun ZonedDateTimeInterval(start: ZonedDateTime, endExclusive: ZonedDateTime)

Types

Companion
Link copied to clipboard
common
object Companion

Functions

asDuration
Link copied to clipboard
common

Converts this interval into a Duration of the same length.

override fun asDuration(): Duration
asPeriod
Link copied to clipboard
common

Converts this interval into a Period of the same length.

fun asPeriod(): Period
contains
Link copied to clipboard
common

Checks if this interval contains value.

open operator override fun contains(value: ZonedDateTime): Boolean
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hasBoundedEnd
Link copied to clipboard
common

Checks if this interval's end is bounded, meaning it has a finite value.

open override fun hasBoundedEnd(): Boolean
hasBoundedStart
Link copied to clipboard
common

Checks if this interval's start is bounded, meaning it has a finite value.

open override fun hasBoundedStart(): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
hasUnboundedEnd
Link copied to clipboard
common

Checks if this interval's end is unbounded. In ISO-8601 terminology, this is an "open" end.

open override fun hasUnboundedEnd(): Boolean
hasUnboundedStart
Link copied to clipboard
common

Checks if this interval's start is unbounded. In ISO-8601 terminology, this is an "open" start.

open override fun hasUnboundedStart(): Boolean
isBounded
Link copied to clipboard
common

Checks if both the start and end of this interval are bounded, meaning it has a finite range.

open override fun isBounded(): Boolean
isEmpty
Link copied to clipboard
common

Checks if this interval is empty.

open override fun isEmpty(): Boolean
isUnbounded
Link copied to clipboard
common

Checks if both the start and end of this interval are unbounded, meaning this is an infinite time period in both directions.

open override fun isUnbounded(): Boolean
toString
Link copied to clipboard
common

Converts this interval to a string in ISO-8601 extended format.

open override fun toString(): String

Properties

endExclusive
Link copied to clipboard
common

The end of this interval, exclusive.

open override val endExclusive: ZonedDateTime
endInclusive
Link copied to clipboard
common

The end of this interval, inclusive.

open override val endInclusive: ZonedDateTime
lengthInDays
Link copied to clipboard
common

The number of whole days in this interval.

open override val lengthInDays: LongDays
lengthInHours
Link copied to clipboard
common

The number of whole hours in this interval.

override val lengthInHours: LongHours
lengthInMicroseconds
Link copied to clipboard
common

The number of whole microseconds in this interval.

override val lengthInMicroseconds: LongMicroseconds
lengthInMilliseconds
Link copied to clipboard
common

The number of whole milliseconds in this interval.

override val lengthInMilliseconds: LongMilliseconds
lengthInMinutes
Link copied to clipboard
common

The number of whole minutes in this interval.

override val lengthInMinutes: LongMinutes
lengthInMonths
Link copied to clipboard
common

The number of whole months is this interval.

val lengthInMonths: IntMonths
lengthInNanoseconds
Link copied to clipboard
common

The number of whole nanoseconds in this interval.

override val lengthInNanoseconds: LongNanoseconds
lengthInSeconds
Link copied to clipboard
common

The number of whole seconds in this interval.

override val lengthInSeconds: LongSeconds
lengthInWeeks
Link copied to clipboard
common

The number of whole weeks in this interval.

val lengthInWeeks: LongWeeks
lengthInYears
Link copied to clipboard
common

The number of whole years in this interval.

val lengthInYears: IntYears
start
Link copied to clipboard
common

The start of this interval, inclusive.

open override val start: ZonedDateTime

Extensions

random
Link copied to clipboard
common

Returns a random date within this interval using the default random number generator. The zone of the start date-time will be used.

fun ZonedDateTimeInterval.random(): ZonedDateTime

Returns a random date within this interval using the supplied random number generator. The zone of the start date-time will be used.

fun ZonedDateTimeInterval.random(random: Random): ZonedDateTime
randomOrNull
Link copied to clipboard
common

Returns a random date within this interval using the default random number generator or null if the interval is empty or unbounded. The zone of the start date-time will be used.

fun ZonedDateTimeInterval.randomOrNull(): ZonedDateTime?

Returns a random date within this interval using the supplied random number generator or null if the interval is empty or unbounded. The zone of the start date-time will be used.

fun ZonedDateTimeInterval.randomOrNull(random: Random): ZonedDateTime?
toDateRange
Link copied to clipboard
common

Returns this interval with the precision reduced to just the date.

fun ZonedDateTimeInterval.toDateRange(): DateRange
toDateTimeInterval
Link copied to clipboard
common

Returns this interval with the precision reduced to only the local date and time.

fun ZonedDateTimeInterval.toDateTimeInterval(): DateTimeInterval
toInstantInterval
Link copied to clipboard
common

Converts this interval to an InstantInterval.

fun ZonedDateTimeInterval.toInstantInterval(): InstantInterval
toOffsetDateTimeInterval
Link copied to clipboard
common

Converts this interval to an OffsetDateTimeInterval.

While similar to ZonedDateTime, an OffsetDateTime representation is unaffected by time zone rule changes or database differences between systems, making it better suited for use cases involving persistence or network transfer.