Question: How to limit on DatePicker to cannot choose date in future. I have DatePicker in activity which is used for registration. What to do so user cannot pick date of birthday if user has less that 18 years ( for example cannot pick date after today\_date - 18 years )?

Answer: 
You didn’t mention which API level. On Honeycomb and later, [DatePicker](http://developer.android.com/reference/android/widget/DatePicker.html) has setMin/MaxDate methods you can use to restrict the permissible range.
Count the year before 18 from now (current year) by int minYear = currentYear - 18; And then set that date with (Min year , current month, current day) as the max limit of the date picker.

```
    private static void setMaxLimitInDatePicker(DatePickerDialog datePickerDialog) {
    final Calendar calendar = Calendar.getInstance();

    int currentYear = calendar.get(Calendar.YEAR);
    int currentMonth = calendar.get(Calendar.MONTH);
    int currentDay = calendar.get(Calendar.DAY_OF_MONTH);

    int minYear = currentYear - 18;
    int minMonth = currentMonth;
    int minDay = currentDay;

    calendar.set(minYear, minMonth, minDay);
    long minDateInMilliSeconds = calendar.getTimeInMillis();

    // Set 18 years from today as max limit of date picker
    datePickerDialog.getDatePicker().setMaxDate(minDateInMilliSeconds);
}

```