parseOrNull

Parses an ISO 8601 week date string as a LocalIsoWeekDate or returns null if the string could not be parsed into a LocalIsoWeekDate.

See parse for the list of supported formats.

See also

for a version of this function that throws an exception on faulty input.

for the dual operation: obtaining a string from a LocalIsoWeekDate.

Samples

import kotlinx.datetime.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // Parsing LocalIsoWeekDate values or failing
check(LocalIsoWeekDate.parseOrNull("2024-W01-5") == LocalIsoWeekDate(2024, 1, DayOfWeek.FRIDAY))
check(LocalIsoWeekDate.parseOrNull("2024-W01-0") == null) 
   //sampleEnd
}