OffsetDateTimeInterval

A half-open interval between two offset date-times based on timeline order.

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

class OffsetDateTimeInterval(start: OffsetDateTime,endExclusive: OffsetDateTime) : TimePointInterval<OffsetDateTime>

Constructors

OffsetDateTimeInterval
Link copied to clipboard
common
fun OffsetDateTimeInterval(start: OffsetDateTime, endExclusive: OffsetDateTime)

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: OffsetDateTime): 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: OffsetDateTime
endInclusive
Link copied to clipboard
common

The end of this interval, inclusive.

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

The number of 24-hour 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 in 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: OffsetDateTime

Extensions

asZonedDateTimeInterval
Link copied to clipboard
common

Converts this interval to an equivalent ZonedDateTimeInterval where both endpoints are given a fixed-offset time zone.

This comes with the caveat that a fixed-offset zone lacks knowledge of any region and will not respond to daylight savings time changes. To convert each endpoint to a region-based zone, use toZonedDateTimeInterval instead.

random
Link copied to clipboard
common

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

fun OffsetDateTimeInterval.random(): OffsetDateTime

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

fun OffsetDateTimeInterval.random(random: Random): OffsetDateTime
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 offset of the start date-time will be used.

fun OffsetDateTimeInterval.randomOrNull(): OffsetDateTime?

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

fun OffsetDateTimeInterval.randomOrNull(random: Random): OffsetDateTime?
toDateRange
Link copied to clipboard
common

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

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

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

toInstantInterval
Link copied to clipboard
common

Converts this interval to an InstantInterval.

fun OffsetDateTimeInterval.toInstantInterval(): InstantInterval
toZonedDateTimeInterval
Link copied to clipboard
common

Converts this interval to a ZonedDateTimeInterval using the specified strategy to adjust each endpoint to a valid date, time, and offset in zone.

Alternatively, you can use asZonedDateTimeInterval to convert each endpoint to a ZonedDateTime with an equivalent fixed-offset zone. However, this comes with the caveat that a fixed-offset zone lacks knowledge of any region and will not respond to daylight savings time changes.