LocalDate

actual constructor(year: Int, month: Int, day: Int)(source)

Constructs a LocalDate instance from the given date components.

The components month and day are 1-based.

The supported ranges of components:

See also

for a version that returns null instead of throwing an exception when the parameters are invalid.

Throws

if any parameter is out of range or if day is invalid for the given month and year.

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
}

actual constructor(year: Int, month: Month, day: Int)(source)

Constructs a LocalDate instance from the given date components.

The supported ranges of components:

See also

for a version that returns null instead of throwing an exception when the parameters are invalid.

Throws

if any parameter is out of range or if day is invalid for the given month and year.

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
}
expect constructor(year: Int, month: Int, day: Int)(source)

Constructs a LocalDate instance from the given date components.

The components month and day are 1-based.

The supported ranges of components:

See also

for a version that returns null instead of throwing an exception when the parameters are invalid.

Throws

if any parameter is out of range or if day is invalid for the given month and year.

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
}

expect constructor(year: Int, month: Month, day: Int)(source)

Constructs a LocalDate instance from the given date components.

The supported ranges of components:

See also

for a version that returns null instead of throwing an exception when the parameters are invalid.

Throws

if any parameter is out of range or if day is invalid for the given month and year.

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
}
actual constructor(year: Int, month: Int, day: Int)(source)

Constructs a LocalDate instance from the given date components.

The components month and day are 1-based.

The supported ranges of components:

See also

for a version that returns null instead of throwing an exception when the parameters are invalid.

Throws

if any parameter is out of range or if day is invalid for the given month and year.

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
}

actual constructor(year: Int, month: Month, day: Int)(source)

Constructs a LocalDate instance from the given date components.

The supported ranges of components:

See also

for a version that returns null instead of throwing an exception when the parameters are invalid.

Throws

if any parameter is out of range or if day is invalid for the given month and year.

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
}