# DateRangePickerState

Artifact: [androidx.compose.material3:material3](https://developer.android.com/jetpack/androidx/releases/compose-material3) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/DateRangePicker.kt+class:androidx.compose.material3.DateRangePickerState) Common/AllAndroid/JVM
- Cmn

  ```
  interface DateRangePickerState
  ```

*** ** * ** ***

A state object that can be hoisted to observe the date range picker state. See `https://developer.android.com/reference/kotlin/androidx/compose/material3/rememberDateRangePickerState.composable#rememberDateRangePickerState(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.ranges.IntRange,androidx.compose.material3.DisplayMode,androidx.compose.material3.SelectableDates)`.

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#setSelection(kotlin.Long,kotlin.Long)(startDateMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html?, endDateMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html?)` Sets a start and end selection dates. | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/DisplayMode` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#displayMode()` A `https://developer.android.com/reference/kotlin/androidx/compose/material3/DisplayMode` that represents the current UI mode (i.e. picker or input). | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#displayedMonthMillis()` A timestamp that represents the currently displayed month *start* date in *UTC* milliseconds from the epoch. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/CalendarLocale` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#locale()` A locale that will be used when formatting dates, determining the input format, week-days, and more. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/SelectableDates` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#selectableDates()` A `https://developer.android.com/reference/kotlin/androidx/compose/material3/SelectableDates` that is consulted to check if a date is allowed. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html?` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#selectedEndDateMillis()` A timestamp that represents the selected end date *start* of the day in *UTC* milliseconds from the epoch. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html?` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#selectedStartDateMillis()` A timestamp that represents the selected start date *start* of the day in *UTC* milliseconds from the epoch. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-int-range/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#yearRange()` An `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-int-range/index.html` that holds the year range that the date picker will be limited to. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/java/time/YearMonth.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState.https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#(androidx.compose.material3.DateRangePickerState).getDisplayedMonth()()` Returns a `https://developer.android.com/reference/java/time/YearMonth.html` representation of the displayed month in this `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState`. | android |
| `https://developer.android.com/reference/java/time/LocalDate.html?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState.https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#(androidx.compose.material3.DateRangePickerState).getSelectedEndDate()()` Returns a `https://developer.android.com/reference/java/time/LocalDate.html` representation of the selected end date in this `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState`, or `null` in case there is no selection. | android |
| `https://developer.android.com/reference/java/time/LocalDate.html?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState.https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#(androidx.compose.material3.DateRangePickerState).getSelectedStartDate()()` Returns a `https://developer.android.com/reference/java/time/LocalDate.html` representation of the selected start date in this `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState`, or `null` in case there is no selection. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState.https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#(androidx.compose.material3.DateRangePickerState).setDisplayedMonth(java.time.YearMonth)(yearMonth: https://developer.android.com/reference/java/time/YearMonth.html)` Sets the `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#displayedMonthMillis()` based on a given `https://developer.android.com/reference/java/time/YearMonth.html`. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState.https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#(androidx.compose.material3.DateRangePickerState).setSelection(java.time.LocalDate,java.time.LocalDate)( startDate: https://developer.android.com/reference/java/time/LocalDate.html?, endDate: https://developer.android.com/reference/java/time/LocalDate.html? )` Sets the `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState` start and end dates selection. | android |

## Public functions

### setSelection

Cmn

```
fun setSelection(startDateMillis: Long?, endDateMillis: Long?): Unit
```

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 `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` is thrown.

| Parameters |
|---|---|
| `startDateMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html?` | timestamp in *UTC* milliseconds from the epoch that represents the start date selection. Provide a `null` to indicate no selection. |
| `endDateMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html?` | timestamp in *UTC* milliseconds from the epoch that represents the end date selection. Provide a `null` to indicate no selection. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | in case the given timestamps do not comply with the expected values specified above. |

## Public properties

### displayMode

Cmn

```
var displayMode: DisplayMode
```

A `https://developer.android.com/reference/kotlin/androidx/compose/material3/DisplayMode` that represents the current UI mode (i.e. picker or input).

### displayedMonthMillis

Cmn

```
var displayedMonthMillis: Long
```

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

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | in case the value is set with a timestamp that does not fall within the `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#yearRange()`. |

### locale

Cmn

```
val locale: CalendarLocale
```

A locale that will be used when formatting dates, determining the input format, week-days, and more.

### selectableDates

Cmn

```
val selectableDates: SelectableDates
```

A `https://developer.android.com/reference/kotlin/androidx/compose/material3/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.

### selectedEndDateMillis

Cmn

```
val selectedEndDateMillis: Long?
```

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#setSelection(kotlin.Long,kotlin.Long)` | for setting this value along with the `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#selectedStartDateMillis()`. |

### selectedStartDateMillis

Cmn

```
val selectedStartDateMillis: Long?
```

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#setSelection(kotlin.Long,kotlin.Long)` | for setting this value along with the `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#selectedEndDateMillis()`. |

### yearRange

Cmn

```
val yearRange: IntRange
```

An `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-int-range/index.html` that holds the year range that the date picker will be limited to.

## Extension functions

### DateRangePickerState.getDisplayedMonth

android Artifact: [androidx.compose.material3:material3](https://developer.android.com/jetpack/androidx/releases/compose-material3) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/DatePicker.jvmAndAndroid.kt+function:getDisplayedMonth)

```
@RequiresApi(value = 26)
fun DateRangePickerState.getDisplayedMonth(): YearMonth
```

Returns a `https://developer.android.com/reference/java/time/YearMonth.html` representation of the displayed month in this `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState`. The returned `https://developer.android.com/reference/java/time/YearMonth.html` is based on the `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#displayedMonthMillis()`, which represents midnight of the first day of the displayed month in UTC milliseconds from the epoch.

| Returns |
|---|---|
| `https://developer.android.com/reference/java/time/YearMonth.html` | The displayed `https://developer.android.com/reference/java/time/YearMonth.html`. |

### DateRangePickerState.getSelectedEndDate

android Artifact: [androidx.compose.material3:material3](https://developer.android.com/jetpack/androidx/releases/compose-material3) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/DatePicker.jvmAndAndroid.kt+function:getSelectedEndDate)

```
@RequiresApi(value = 26)
fun DateRangePickerState.getSelectedEndDate(): LocalDate?
```

Returns a `https://developer.android.com/reference/java/time/LocalDate.html` representation of the selected end date in this `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState`, or `null` in case there is no selection.

| Returns |
|---|---|
| `https://developer.android.com/reference/java/time/LocalDate.html?` | The selected end `https://developer.android.com/reference/java/time/LocalDate.html`, or `null` if there is no selection. |

### DateRangePickerState.getSelectedStartDate

android Artifact: [androidx.compose.material3:material3](https://developer.android.com/jetpack/androidx/releases/compose-material3) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/DatePicker.jvmAndAndroid.kt+function:getSelectedStartDate)

```
@RequiresApi(value = 26)
fun DateRangePickerState.getSelectedStartDate(): LocalDate?
```

Returns a `https://developer.android.com/reference/java/time/LocalDate.html` representation of the selected start date in this `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState`, or `null` in case there is no selection.

| Returns |
|---|---|
| `https://developer.android.com/reference/java/time/LocalDate.html?` | The selected start `https://developer.android.com/reference/java/time/LocalDate.html`, or `null` if there is no selection. |

### DateRangePickerState.setDisplayedMonth

android Artifact: [androidx.compose.material3:material3](https://developer.android.com/jetpack/androidx/releases/compose-material3) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/DatePicker.jvmAndAndroid.kt+function:setDisplayedMonth)

```
@RequiresApi(value = 26)
fun DateRangePickerState.setDisplayedMonth(yearMonth: YearMonth): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState#displayedMonthMillis()` based on a given `https://developer.android.com/reference/java/time/YearMonth.html`.

Converts the `https://developer.android.com/reference/java/time/YearMonth.html` to the start of the first day of that month (midnight) in UTC and apply it to the `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState` `displayedMonthMillis`.

| Parameters |
|---|---|
| `yearMonth: https://developer.android.com/reference/java/time/YearMonth.html` | The `https://developer.android.com/reference/java/time/YearMonth.html` to display. |

### DateRangePickerState.setSelection

android Artifact: [androidx.compose.material3:material3](https://developer.android.com/jetpack/androidx/releases/compose-material3) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/DatePicker.jvmAndAndroid.kt+function:setSelection)

```
@RequiresApi(value = 26)
fun DateRangePickerState.setSelection(
    startDate: LocalDate?,
    endDate: LocalDate?
): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState` start and end dates selection.

The provided `https://developer.android.com/reference/java/time/LocalDate.html`s are converted to the start of the day (midnight) in UTC and applied to the `https://developer.android.com/reference/kotlin/androidx/compose/material3/DateRangePickerState`.

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 `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` is thrown.

| Parameters |
|---|---|
| `startDate: https://developer.android.com/reference/java/time/LocalDate.html?` | a `https://developer.android.com/reference/java/time/LocalDate.html` that represents the start date selection. Provide a `null` to indicate no selection. |
| `endDate: https://developer.android.com/reference/java/time/LocalDate.html?` | a `https://developer.android.com/reference/java/time/LocalDate.html` that represents the end date selection. Provide a `null` to indicate no selection. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | in case the given `https://developer.android.com/reference/java/time/LocalDate.html`s do not comply with the expected values specified above. |