toLocalTime

Builds a LocalTime from the fields in this DateTimeComponents.

This method uses the following fields:

Throws

if hours or minutes are not present, if any of the fields are invalid, or hourOfAmPm and amPm are inconsistent with hour.

Samples

import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   // Obtaining a LocalTime from the parsed data
val rfc1123Input = "Sun, 06 Nov 1994 08:49:37 +0300"
val parsed = DateTimeComponents.Formats.RFC_1123.parse(rfc1123Input)
val localTime = parsed.toLocalTime()
check(localTime == LocalTime(8, 49, 37)) 
   //sampleEnd
}