material-components / material-components/material-components-android
[MaterialDatePicker] Add option to configure set2DigitYearStart
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Currently when setting a max date (e.g. the current day) the text input validation of the DateFormatTextWatcher format allows entering future years that lead to validation errors.
For example:
The time range for my birthday picker is: 1900 - Today
When I enter the year: **01/01/40** is in parsed to **01/01/2040** due to the default implementation of the SimpleDateFormat.
As this date is beyond the ranges, I would expected it to be 1940 instead.
It would be good if we as developers would be able to define the SimpleDateFormat.set2DigitYearStart if needed to prevent the problem described above.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing MaterialDatePicker's text-input path to DateFormatTextWatcher and inspect how its SimpleDateFormat is created and used for range validation. Add a way for callers to configure the two-digit-year start, then verify that an input such as 01/01/40 can resolve within a 1900–today range without producing a future-date validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100