use date from 1970-01-01 to 2037-12-31 in DatePickerDialog
In case of using DatePickerDialog, user could select any date before 1970-01-01. However, the system clock cannot be set to a date before 1970-01-01. As a result, user couldn't select date before 1970-01-01. So, use date from 1970-01-01 to 2037-12-31 of DatePickerDialog. Steps to reproduce: 1. Settings -> Date & time 2. uncheck Automatic date & time 3. Set Date 4. choose any date before 1970 and Done Change-Id: I075b3fcaa86df1c314c85dd3dd85474a28b8c637
This commit is contained in:
committed by
Elliott Hughes
parent
506b68e1c5
commit
7ccfa0614c
@@ -244,6 +244,15 @@ public class DateTimeSettings extends SettingsPreferenceFragment
|
|||||||
calendar.get(Calendar.YEAR),
|
calendar.get(Calendar.YEAR),
|
||||||
calendar.get(Calendar.MONTH),
|
calendar.get(Calendar.MONTH),
|
||||||
calendar.get(Calendar.DAY_OF_MONTH));
|
calendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
// The system clock can't represent dates outside this range.
|
||||||
|
DatePickerDialog datePicker = (DatePickerDialog)d;
|
||||||
|
Calendar t = Calendar.getInstance();
|
||||||
|
t.clear();
|
||||||
|
t.set(1970, Calendar.JANUARY, 1);
|
||||||
|
datePicker.getDatePicker().setMinDate(t.getTimeInMillis());
|
||||||
|
t.clear();
|
||||||
|
t.set(2037, Calendar.DECEMBER, 31);
|
||||||
|
datePicker.getDatePicker().setMaxDate(t.getTimeInMillis());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIALOG_TIMEPICKER: {
|
case DIALOG_TIMEPICKER: {
|
||||||
|
Reference in New Issue
Block a user