inWholeNanoseconds

The value of this duration expressed as a Long number of nanoseconds.

If the result doesn't fit in the range of Long type, it is coerced into that range:

An infinite duration value is converted either to Long.MAX_VALUE or Long.MIN_VALUE depending on its sign.

Since Kotlin

1.6

Samples

import kotlin.test.*
import kotlin.time.*
import kotlin.time.Duration.Companion.days
import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.microseconds
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.nanoseconds
import kotlin.time.Duration.Companion.seconds

fun main() { 
   //sampleStart 
   println(3.milliseconds.inWholeNanoseconds) // 3000000

println("1_000_000_000.days.inWholeNanoseconds == Long.MAX_VALUE is ${1_000_000_000.days.inWholeNanoseconds == Long.MAX_VALUE}") // true
println("(-Duration.INFINITE).inWholeNanoseconds == Long.MIN_VALUE is ${(-Duration.INFINITE).inWholeNanoseconds == Long.MIN_VALUE}") // true 
   //sampleEnd
}