int mMonth = 0, mDay = 0, mYear = 0;
DatePickerDialog mDatePicker = new DatePickerDialog(activity_registrationactivityy.this, new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
Calendar mcurrentDate = Calendar.getInstance();
int mYear = selectedyear;
int mMonth = selectedmonth;
int mDay = selectedday;
DatePickerDialog dpDialog = new DatePickerDialog(getApplicationContext(), mDatePicker, mYear, mMonth, mDay);
dpDialog.getDatePicker().setMaxDate(mcurrentDate.getTimeInMillis());
et_birthdate.setText(new StringBuilder().append(mDay).append("/").append(mMonth + 1).append("/").append(mYear));
//takes current date
}
}, m`enter code here`Year, mMonth, mDay);
mDatePicker.setTitle("Select date");
mDatePicker.show();
Asked
Active
Viewed 405 times
0

Avag Sargsyan
- 2,437
- 3
- 28
- 41

shanaya
- 1
-
2Possible duplicate of [How to Disable future dates in Android date picker](https://stackoverflow.com/questions/20970963/how-to-disable-future-dates-in-android-date-picker) – Learning Always Jan 08 '18 at 09:15
2 Answers
0
You can use the method setMaxDate(long maxDate)
To disable future dates use the following:
dpDialog.getDatePicker().setMaxDate(System.currentTimeMillis());

Rahul Sharma
- 2,867
- 2
- 27
- 40
0
try this
DatePickerDialog dpDialog = new DatePickerDialog(getContext(), myDateListener, mYear, mMonth, mDay);
dpDialog.getDatePicker().setMaxDate(calendar.getTimeInMillis());

Vikas singh
- 3,461
- 3
- 14
- 28