from Epoch Milliseconds
Returns an Instant that is epochMilliseconds number of milliseconds from the epoch instant 1970-01-01T00:00:00Z
.
The return value is clamped to the platform-specific boundaries for Instant if the result exceeds them. In any case, it is guaranteed that instants between DISTANT_PAST and DISTANT_FUTURE can be represented.
Note that Instant also supports nanosecond precision via fromEpochSeconds.
See also
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.random.*
import kotlin.test.*
import kotlin.time.Duration.Companion.hours
fun main() {
//sampleStart
// Constructing an Instant from the number of milliseconds since the Unix epoch
check(Instant.fromEpochMilliseconds(epochMilliseconds = 0) == Instant.parse("1970-01-01T00:00:00Z"))
check(Instant.fromEpochMilliseconds(epochMilliseconds = 1_000_000_000_123)
== Instant.parse("2001-09-09T01:46:40.123Z"))
//sampleEnd
}