orNull
Constructs a LocalIsoWeekDate instance from the given date components or returns null if a value is out of range or invalid.
The supported ranges of components:
isoWeekYear the range is at least enough to represent dates of all instants between Instant.DISTANT_PAST and Instant.DISTANT_FUTURE
isoWeekNumber
1..52or1..53, depending on the isoWeekYear
Use LocalIsoWeekDate(isoWeekYear, isoWeekNumber, dayOfWeek) to throw an exception instead of returning null when the parameters are invalid.
Samples
import kotlinx.datetime.*
import kotlin.test.*
fun main() {
//sampleStart
// Constructing a LocalIsoWeekDate or returning null if components are out of range
check(LocalIsoWeekDate.orNull(2004, 53, DayOfWeek.SATURDAY) == LocalIsoWeekDate(2004, 53, DayOfWeek.SATURDAY))
check(LocalIsoWeekDate.orNull(2004, 54, DayOfWeek.SATURDAY) == null)
//sampleEnd
}Constructs a LocalIsoWeekDate instance from the given date components or returns null if a value is out of range or invalid.
The components isoWeekNumber and dayOfWeek are 1-based.
The supported ranges of components:
isoWeekYear the range is at least enough to represent dates of all instants between Instant.DISTANT_PAST and Instant.DISTANT_FUTURE
isoWeekNumber
1..52or1..53, depending on the isoWeekYeardayOfWeek
1..7
Use LocalIsoWeekDate(isoWeekYear, isoWeekNumber, dayOfWeek) to throw an exception instead of returning null when the parameters are invalid.
Samples
import kotlinx.datetime.*
import kotlin.test.*
fun main() {
//sampleStart
// Constructing a LocalIsoWeekDate or returning null if components are out of range
check(LocalIsoWeekDate.orNull(2004, 53, 6) == LocalIsoWeekDate(2004, 53, 6))
check(LocalIsoWeekDate.orNull(2004, 53, 8) == null)
//sampleEnd
}