DatePickerState

fun DatePickerState(locale: CalendarLocale, initialSelectedDateMillis: Long? = null, initialDisplayedMonthMillis: Long? = initialSelectedDateMillis, yearRange: IntRange = DatePickerDefaults.YearRange, initialDisplayMode: DisplayMode = DisplayMode.Picker, selectableDates: SelectableDates = DatePickerDefaults.AllDates): DatePickerState

Creates a DatePickerState.

Note that in most cases, you are advised to use the rememberDatePickerState when in a composition.

Parameters

locale

a CalendarLocale to be used when formatting dates, determining the input format, and more

initialSelectedDateMillis

timestamp in UTC milliseconds from the epoch that represents an initial selection of a date. Provide a null to indicate no selection. Note that the state's DatePickerState.selectedDateMillis will provide a timestamp that represents the start of the day, which may be different than the provided initialSelectedDateMillis.

initialDisplayedMonthMillis

timestamp in UTC milliseconds from the epoch that represents an initial selection of a month to be displayed to the user. In case null is provided, the displayed month would be the current one.

yearRange

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

initialDisplayMode

an initial DisplayMode that this state will hold

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.

See also

Throws

if the initial selected date or displayed month represent a year that is out of the year range.