InstantInterval

A half-open interval between two instants.

Instant.MIN and Instant.MAX are used as sentinels to indicate an unbounded (ie. infinite) start or end.

class InstantInterval(start: Instant,endExclusive: Instant) : TimePointInterval<Instant> , TimePointProgressionBuilder<Instant>

Constructors

InstantInterval
Link copied to clipboard
common
fun InstantInterval(start: Instant, endExclusive: Instant)

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
contains
Link copied to clipboard
common

Checks if this interval contains value.

open operator override fun contains(value: Instant): 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: Instant
endInclusive
Link copied to clipboard
common

The end of this interval, inclusive.

open override val endInclusive: Instant
first
Link copied to clipboard
common
open override val first: Instant
last
Link copied to clipboard
common
open override val last: Instant
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
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
start
Link copied to clipboard
common

The start of this interval, inclusive.

open override val start: Instant

Extensions

at
Link copied to clipboard
common

Combines this InstantInterval with a TimeZone to create an equivalent ZonedDateTimeInterval where both endpoints are in zone.

infix fun InstantInterval.at(zone: TimeZone): ZonedDateTimeInterval
random
Link copied to clipboard
common

Returns a random date within this interval using the default random number generator.

fun InstantInterval.random(): Instant

Returns a random date within this interval using the supplied random number generator.

fun InstantInterval.random(random: Random): Instant
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.

fun InstantInterval.randomOrNull(): Instant?

Returns a random date within this interval using the supplied random number generator or null if the interval is empty or unbounded.

fun InstantInterval.randomOrNull(random: Random): Instant?
toDateRangeAt
Link copied to clipboard
common

Converts this interval to the equivalent DateRange when both endpoints are in zone.

fun InstantInterval.toDateRangeAt(zone: TimeZone): DateRange
toDateTimeIntervalAt
Link copied to clipboard
common

Converts this interval to the equivalent DateTimeInterval when both endpoints are in zone.

fun InstantInterval.toDateTimeIntervalAt(zone: TimeZone): DateTimeInterval