isDistantFuture

Returns true if the instant is Instant.DISTANT_FUTURE or later.

Since Kotlin

2.1

Samples

import kotlin.test.*
import kotlin.time.*
import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.nanoseconds

fun main() { 
   //sampleStart 
   // Checking if an instant is so far in the future that it's probably irrelevant.
val yearTenThousand = Instant.parse("+10000-01-01T00:00:00Z")
println(yearTenThousand.isDistantFuture) // false

// Instant.DISTANT_FUTURE is the earliest instant that is considered far in the future.
println(Instant.DISTANT_FUTURE) // +100000-01-01T00:00:00Z
println(Instant.DISTANT_FUTURE.isDistantFuture) // true

// All instants later than Instant.DISTANT_FUTURE are considered to be far in the future.
val laterThanDistantFuture = Instant.DISTANT_FUTURE + 1.nanoseconds
println(laterThanDistantFuture) // +100000-01-01T00:00:00.000000001Z
println(laterThanDistantFuture.isDistantFuture) // true

// All instants earlier than Instant.DISTANT_FUTURE are not considered to be far in the future.
val earlierThanDistantFuture = Instant.DISTANT_FUTURE - 1.nanoseconds
println(earlierThanDistantFuture) // +99999-12-31T23:59:59.999999999Z
println(earlierThanDistantFuture.isDistantFuture) // false 
   //sampleEnd
}