{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

DatePickerState

@ExperimentalMaterial3Api
public interface DatePickerState


A state object that can be hoisted to observe the date picker state. See rememberDatePickerState.

Summary

Public methods

abstract @NonNull DisplayMode

A DisplayMode that represents the current UI mode (i.e. picker or input).

abstract long

A timestamp that represents the currently displayed month start date in UTC milliseconds from the epoch.

abstract @NonNull SelectableDates

A SelectableDates that is consulted to check if a date is allowed.

abstract Long

A timestamp that represents the selected date start of the day in UTC milliseconds from the epoch.

abstract @NonNull IntRange

An IntRange that holds the year range that the date picker will be limited to.

abstract void

A DisplayMode that represents the current UI mode (i.e. picker or input).

abstract void
setDisplayedMonthMillis(long displayedMonthMillis)

A timestamp that represents the currently displayed month start date in UTC milliseconds from the epoch.

abstract void
setSelectedDateMillis(Long selectedDateMillis)

A timestamp that represents the selected date start of the day in UTC milliseconds from the epoch.

Public methods

getDisplayMode

abstract @NonNull DisplayMode getDisplayMode()

A DisplayMode that represents the current UI mode (i.e. picker or input).

getDisplayedMonthMillis

abstract long getDisplayedMonthMillis()

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 yearRange.

getSelectableDates

abstract @NonNull SelectableDates getSelectableDates()

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.

getSelectedDateMillis

abstract Long getSelectedDateMillis()

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 yearRange.

getYearRange

abstract @NonNull IntRange getYearRange()

An IntRange that holds the year range that the date picker will be limited to.

setDisplayMode

abstract void setDisplayMode(@NonNull DisplayMode displayMode)

A DisplayMode that represents the current UI mode (i.e. picker or input).

setDisplayedMonthMillis

abstract void setDisplayedMonthMillis(long displayedMonthMillis)

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 yearRange.

setSelectedDateMillis

abstract void setSelectedDateMillis(Long selectedDateMillis)

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 yearRange.