DatePickerState
-
Cmn
interface DatePickerState
A state object that can be hoisted to observe the date picker state. See rememberDatePickerState.
Summary
Public properties |
||
|---|---|---|
DisplayMode |
A |
Cmn
|
Long |
A timestamp that represents the currently displayed month start date in UTC milliseconds from the epoch. |
Cmn
|
CalendarLocale |
A locale that will be used when formatting dates, determining the input format, week-days, and more. |
Cmn
|
SelectableDates |
A |
Cmn
|
Long? |
A timestamp that represents the selected date start of the day in UTC milliseconds from the epoch. |
Cmn
|
IntRange |
An |
Cmn
|
Extension functions |
||
|---|---|---|
YearMonth |
@RequiresApi(value = 26)Returns a |
android
|
LocalDate? |
@RequiresApi(value = 26)Returns a |
android
|
Unit |
@RequiresApi(value = 26)Sets the |
android
|
Unit |
@RequiresApi(value = 26)Sets the |
android
|
Public properties
displayMode
var displayMode: DisplayMode
A DisplayMode that represents the current UI mode (i.e. picker or input).
displayedMonthMillis
var displayedMonthMillis: Long
A timestamp that represents the currently displayed month start date in UTC milliseconds from the epoch.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
in case the value is set with a timestamp that does not fall within the |
locale
val locale: CalendarLocale
A locale that will be used when formatting dates, determining the input format, week-days, and more.
selectableDates
val selectableDates: SelectableDates
A SelectableDates that is consulted to check if a date is allowed.
In case a date is not allowed to be selected, it will appear disabled in the UI.
selectedDateMillis
var selectedDateMillis: Long?
A timestamp that represents the selected date start of the day in UTC milliseconds from the epoch.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
in case the value is set with a timestamp that does not fall within the |
Extension functions
getDisplayedMonth
@RequiresApi(value = 26)
@ExperimentalMaterial3Api
fun DatePickerState.getDisplayedMonth(): YearMonth
Returns a YearMonth representation of the displayed month in this DatePickerState. The returned YearMonth is based on the DatePickerState.displayedMonthMillis, which represents midnight of the first day of the displayed month in UTC milliseconds from the epoch.
getSelectedDate
@RequiresApi(value = 26)
@ExperimentalMaterial3Api
fun DatePickerState.getSelectedDate(): LocalDate?
Returns a LocalDate representation of the selected date in this DatePickerState, or null in case there is no selection.
setDisplayedMonth
@RequiresApi(value = 26)
@ExperimentalMaterial3Api
fun DatePickerState.setDisplayedMonth(yearMonth: YearMonth): Unit
Sets the DatePickerState.displayedMonthMillis based on a given YearMonth.
Converts the YearMonth to the start of the first day of that month (midnight) in UTC and apply it to the DatePickerState displayedMonthMillis.
setSelectedDate
@RequiresApi(value = 26)
@ExperimentalMaterial3Api
fun DatePickerState.setSelectedDate(date: LocalDate?): Unit
Sets the DatePickerState.selectedDateMillis based on a given LocalDate.
Converts the LocalDate to the start of the day (midnight) in UTC and apply it to the DatePickerState selectedDateMillis. Setting null clears the selection.