android datepicker 18 year old validation
try using the Calendar class.
public void onDateSet(DatePicker view, int year, int month, int day) {
Calendar userAge = new GregorianCalendar(year,month,day);
Calendar minAdultAge = new GregorianCalendar();
minAdultAge.add(Calendar.YEAR, -18);
if (minAdultAge.before(userAge)) {
SHOW_ERROR_MESSAGE;
}
}
this should do what you want :)
Try this
datePickerDialog.getDatePicker().setMaxDate(System.currentTimeMillis() - 568025136000L);