LocalDate
Constructs a LocalDate instance from the given date components.
The components month and day are 1-based.
The supported ranges of components:
year the range is at least enough to represent dates of all instants between Instant.DISTANT_PAST and Instant.DISTANT_FUTURE
month
1..12day
1..31, the upper bound can be less, depending on the month
Throws
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.random.*
import kotlin.test.*
fun main() {
//sampleStart
// Constructing a LocalDate value using its constructor
val date = LocalDate(2024, 4, 16)
check(date.year == 2024)
check(date.month.number == 4)
check(date.month == Month.APRIL)
check(date.day == 16)
//sampleEnd
}Constructs a LocalDate instance from the given date components.
The supported ranges of components:
year the range at least is enough to represent dates of all instants between Instant.DISTANT_PAST and Instant.DISTANT_FUTURE
day
1..31, the upper bound can be less, depending on the month
Throws
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.random.*
import kotlin.test.*
fun main() {
//sampleStart
// Constructing a LocalDate value using its constructor
val date = LocalDate(2024, Month.APRIL, 16)
check(date.year == 2024)
check(date.month == Month.APRIL)
check(date.day == 16)
//sampleEnd
}