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

DateRangePickerState

@ExperimentalMaterial3Api
public interface DateRangePickerState


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

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 end date start of the day in UTC milliseconds from the epoch.

abstract Long

A timestamp that represents the selected start 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
setSelection(Long startDateMillis, Long endDateMillis)

Sets a start and end selection dates.

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.

getSelectedEndDateMillis

abstract Long getSelectedEndDateMillis()

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

See also
setSelection

for setting this value along with the selectedStartDateMillis.

getSelectedStartDateMillis

abstract Long getSelectedStartDateMillis()

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

See also
setSelection

for setting this value along with the selectedEndDateMillis.

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.

setSelection

abstract void setSelection(Long startDateMillis, Long endDateMillis)

Sets a start and end selection dates.

The function expects the dates to be within the state's year-range, and for the start date to appear before, or be equal, the end date. Also, if an end date is provided (e.g. not null), a start date is also expected to be provided. In any other case, an IllegalArgumentException is thrown.

Parameters
Long startDateMillis

timestamp in UTC milliseconds from the epoch that represents the start date selection. Provide a null to indicate no selection.

Long endDateMillis

timestamp in UTC milliseconds from the epoch that represents the end date selection. Provide a null to indicate no selection.

Throws
kotlin.IllegalArgumentException

in case the given timestamps do not comply with the expected values specified above.