nanosecond
Returns the nanosecond-of-second (0..999_999_999
) time component of this datetime value.
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() {
//sampleStart
// Accessing the time components of a LocalDateTime value
val date = LocalDate(2024, 2, 15)
val time = LocalTime(hour = 16, minute = 48, second = 59, nanosecond = 999_999_999)
val dateTime = LocalDateTime(date, time)
check(dateTime.hour == dateTime.time.hour)
check(dateTime.minute == dateTime.time.minute)
check(dateTime.second == dateTime.time.second)
check(dateTime.nanosecond == dateTime.time.nanosecond)
//sampleEnd
}