InstantInterval

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

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.

Constructors

InstantInterval
Link copied to clipboard
common
fun InstantInterval(start: Instant = Instant.MIN, endExclusive: Instant = Instant.MAX)

Types

Companion
Link copied to clipboard
common
object Companion

Functions

contains
Link copied to clipboard
common
open operator override fun contains(value: Instant): Boolean

Checks if this interval contains value.

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

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

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

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

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

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

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

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

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

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

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

Checks if this interval is empty.

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

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

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

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

Properties

endExclusive
Link copied to clipboard
common
open override val endExclusive: Instant

The end of this interval, exclusive.

endInclusive
Link copied to clipboard
common
open override val endInclusive: Instant

The end of this interval, inclusive.

first
Link copied to clipboard
common
open override val first: Instant
last
Link copied to clipboard
common
open override val last: Instant
start
Link copied to clipboard
common
open override val start: Instant

The start of this interval, inclusive.

Extensions

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

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

random
Link copied to clipboard
common
fun InstantInterval.random(): Instant

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

fun InstantInterval.random(random: Random): Instant

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

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

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(random: Random): Instant?

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

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

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

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

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