Ad

How To Open DatePicker From Current Date To 18 Years Back?

- 1 answer

I want to open my DatePicker from current date to 18 years back for DateofBirth Validation.

Ad

Answer

Just Add below line

 myCalendar.add(Calendar.YEAR,-18)
 new DatePickerDialog(getActivity(), dateExpiry, myCalendar
                    .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
                    myCalendar.get(Calendar.DAY_OF_MONTH)).show();
        }
Ad
source: stackoverflow.com
Ad