DatePickerState

class DatePickerState(initialYear: Int, initialMonth: Int, initialDay: Int)

State holder for the DatePicker.

Manages the state of the year, month, and day pickers. Automatically adjusts the selected day if it exceeds the maximum valid day for the new year/month. Internal picker states are not directly accessible to prevent inconsistent state modifications.

Parameters

initialYear

The initial year to be selected. Must be in 1000..9999.

initialMonth

The initial month to be selected. Must be in 1..12.

initialDay

The initial day to be selected. Must be at least 1. Values greater than the maximum valid day for initialYear and initialMonth are clamped to that maximum.

Throws

if initialYear or initialMonth is outside the supported range, or if initialDay is less than 1.

Constructors

Link copied to clipboard
constructor(initialYear: Int, initialMonth: Int, initialDay: Int)
constructor(initialDate: LocalDate)

Creates a DatePickerState from initialDate.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val maxDay: Int

The currently valid maximum day for the selected year and month. Calculated dynamically based on the selected year and month.

Link copied to clipboard
val selectedDate: LocalDate

The currently selected date.

Link copied to clipboard

The currently selected day (1-31).

Link copied to clipboard

The currently selected month (1-12).

Link copied to clipboard

The currently selected year.

Functions

Link copied to clipboard
fun selectDate(date: LocalDate)

Programmatically selects date.

fun selectDate(date: LocalDate, items: DatePickerItems)

Programmatically selects the closest date to date that is allowed by items.

fun selectDate(year: Int, month: Int, day: Int)

Programmatically selects year, month, and day.

fun selectDate(year: Int, month: Int, day: Int, items: DatePickerItems)

Programmatically selects the closest date to year, month, and day that is allowed by items.