# MaterialDatePicker.Builder

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/datepicker/MaterialDatePicker.java)

*** ** * ** ***


```
public final class MaterialDatePicker.Builder<S>
```

<br />

*** ** * ** ***

Used to create MaterialDatePicker instances with default and overridden settings

## Summary

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#build()()` Creates a `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker` with the provided options. |
| `static https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<https://developer.android.com/reference/java/lang/Long>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#datePicker()()` Used to create a Builder that allows for choosing a single date in the ` MaterialDatePicker`. |
| `static https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<Pair<Long, Long>>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#dateRangePicker()()` Used to create a Builder that allows for choosing a date range in the ` MaterialDatePicker`. |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setCalendarConstraints(com.google.android.material.datepicker.CalendarConstraints)(https://developer.android.com/reference/com/google/android/material/datepicker/CalendarConstraints bounds)` Sets the first, last, and starting month. |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setDayViewDecorator(com.google.android.material.datepicker.DayViewDecorator)(https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator dayViewDecorator)` Sets the `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator`. |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setInputMode(int)(int inputMode)` Sets the input mode to start with. |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setNegativeButtonContentDescription(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence contentDescription)` Sets the content description used in the negative button |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setNegativeButtonContentDescription(int)(int contentDescriptionId)` Sets the content description used in the negative button |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setNegativeButtonText(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence text)` Sets the text used in the negative button |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setNegativeButtonText(int)(int textId)` Sets the text used in the negative button |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setPositiveButtonContentDescription(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence contentDescription)` Sets the content description used in the positive button |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setPositiveButtonContentDescription(int)(int contentDescriptionId)` Sets the content description used in the positive button |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setPositiveButtonText(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence text)` Sets the text used in the positive button |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setPositiveButtonText(int)(int textId)` Sets the text used in the positive button |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setSelection(S)(S selection)` |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setTextInputFormat(java.text.SimpleDateFormat)(https://developer.android.com/reference/java/text/SimpleDateFormat format)` Sets the formatter that will be used to input dates using a keyboard. |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setTheme(int)(int themeResId)` Sets the theme controlling fullscreen mode as well as other styles. |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setTitleText(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence charSequence)` Sets the text used to guide the user at the top of the picker. |
| `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder<S>` | `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker.Builder#setTitleText(int)(int titleTextResId)` Sets the text used to guide the user at the top of the picker. |

## Public methods

### build

```
public MaterialDatePicker<S> build()
```

Creates a `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker` with the provided options.

### datePicker

```
public static MaterialDatePicker.Builder<Long> datePicker()
```

Used to create a Builder that allows for choosing a single date in the `
MaterialDatePicker`.

### dateRangePicker

```
public static MaterialDatePicker.Builder<Pair<Long, Long>> dateRangePicker()
```

Used to create a Builder that allows for choosing a date range in the `
MaterialDatePicker`.

### setCalendarConstraints

```
public MaterialDatePicker.Builder<S> setCalendarConstraints(CalendarConstraints bounds)
```

Sets the first, last, and starting month.

### setDayViewDecorator

```
public MaterialDatePicker.Builder<S> setDayViewDecorator(DayViewDecorator dayViewDecorator)
```

Sets the `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator`.

### setInputMode

```
public MaterialDatePicker.Builder<S> setInputMode(int inputMode)
```

Sets the input mode to start with.

### setNegativeButtonContentDescription

```
public MaterialDatePicker.Builder<S> setNegativeButtonContentDescription(CharSequence contentDescription)
```

Sets the content description used in the negative button

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence contentDescription` | content description used in the negative button |

### setNegativeButtonContentDescription

```
public MaterialDatePicker.Builder<S> setNegativeButtonContentDescription(int contentDescriptionId)
```

Sets the content description used in the negative button

| Parameters |
|---|---|
| `int contentDescriptionId` | resource id to be used as content description in the negative button |

### setNegativeButtonText

```
public MaterialDatePicker.Builder<S> setNegativeButtonText(CharSequence text)
```

Sets the text used in the negative button

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence text` | text used in the negative button |

### setNegativeButtonText

```
public MaterialDatePicker.Builder<S> setNegativeButtonText(int textId)
```

Sets the text used in the negative button

| Parameters |
|---|---|
| `int textId` | resource id to be used as text in the negative button |

### setPositiveButtonContentDescription

```
public MaterialDatePicker.Builder<S> setPositiveButtonContentDescription(CharSequence contentDescription)
```

Sets the content description used in the positive button

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence contentDescription` | content description used in the positive button |

### setPositiveButtonContentDescription

```
public MaterialDatePicker.Builder<S> setPositiveButtonContentDescription(int contentDescriptionId)
```

Sets the content description used in the positive button

| Parameters |
|---|---|
| `int contentDescriptionId` | resource id to be used as content description in the positive button |

### setPositiveButtonText

```
public MaterialDatePicker.Builder<S> setPositiveButtonText(CharSequence text)
```

Sets the text used in the positive button

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence text` | text used in the positive button |

### setPositiveButtonText

```
public MaterialDatePicker.Builder<S> setPositiveButtonText(int textId)
```

Sets the text used in the positive button

| Parameters |
|---|---|
| `int textId` | resource id to be used as text in the positive button |

### setSelection

```
public MaterialDatePicker.Builder<S> setSelection(S selection)
```

### setTextInputFormat

```
public MaterialDatePicker.Builder<S> setTextInputFormat(SimpleDateFormat format)
```

Sets the formatter that will be used to input dates using a keyboard.

This affects the hint text and error suggestions of the date input field. Using this setter requires caution to ensure dates are formatted properly in different languages and locales.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/text/SimpleDateFormat format` | a `https://developer.android.com/reference/java/text/SimpleDateFormat` used to format text input dates |

### setTheme

```
public MaterialDatePicker.Builder<S> setTheme(int themeResId)
```

Sets the theme controlling fullscreen mode as well as other styles.

### setTitleText

```
public MaterialDatePicker.Builder<S> setTitleText(CharSequence charSequence)
```

Sets the text used to guide the user at the top of the picker. Setting to null will use a default title based upon the type of selection.

### setTitleText

```
public MaterialDatePicker.Builder<S> setTitleText(int titleTextResId)
```

Sets the text used to guide the user at the top of the picker. Defaults to a standard title based upon the type of selection.