to Local Date
Builds a LocalDate from the fields in this DateTimeComponents.
This method uses the following fields:
Alternatively, the following fields can be used:
If both sets of fields are specified, they are checked for consistency. Also, dayOfWeek is checked for consistency with the other fields.
Throws
if any of the fields is missing or invalid.
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
import kotlin.time.Instant
fun main() {
//sampleStart
// Obtaining a LocalDate from the parsed data
val rfc1123Input = "Sun, 06 Nov 1994 08:49:37 +0300"
val parsed = DateTimeComponents.Formats.RFC_1123.parse(rfc1123Input)
val localDate = parsed.toLocalDate()
check(localDate == LocalDate(1994, 11, 6))
//sampleEnd
}