Spec-Zone.ru › Kotlin 2

DISTANT_PAST

kotlin-stdlib/kotlin.time/Instant/Companion/DISTANT_PAST

Версия Kotlin: 2.3

val DISTANT_PAST: Instant

Момент времени, находящийся далеко в прошлом.

isDistantPast возвращает true для этого значения и всех более ранних значений.

Примеры

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

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

// Instant.DISTANT_PAST is the latest instant that is considered far in the past.
println(Instant.DISTANT_PAST) // -100001-12-31T23:59:59.999999999Z
println(Instant.DISTANT_PAST.isDistantPast) // true

// All instants earlier than Instant.DISTANT_PAST are considered to be far in the past.
val earlierThanDistantPast = Instant.DISTANT_PAST - 1.nanoseconds
println(earlierThanDistantPast) // -100001-12-31T23:59:59.999999998Z
println(earlierThanDistantPast.isDistantPast) // true

// All instants later than Instant.DISTANT_PAST are not considered to be far in the past.
val laterThanDistantPast = Instant.DISTANT_PAST + 1.nanoseconds
println(laterThanDistantPast) // -100000-01-01T00:00:00Z
println(laterThanDistantPast.isDistantPast) // false 
   //sampleEnd
}

© 2010–2026 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-instant/-companion/-d-i-s-t-a-n-t_-p-a-s-t.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API