Q:

DatePickerDialog setMaxDate show one month and one day additional

I have a dialog dAte picker like this:
                     public Dialog onCreateDialog(Bundle savedInstanceState) {
        final Calendar calendar = Calendar.getInstance();
        int yy = calendar.get(Calendar. YEAR);
        int mm = calendar.get(Calendar. MONTH);
        int dd = calendar.get(Calendar. DAY_OF_MONTH);
        DatePickerDialog datePicker = new DatePickerDialog(getActivity(), this, yy, mm, dd);
        datePicker.getDatePicker().setCalendarViewShown(false);

        datePicker.getDatePicker().setMaxDate(new Date().getTime());

        datePicker.setTitle("RENTRE TA DATE DE NAISSANCE."); 

        return datePicker;
    }

We can see my problem On the image the date of today is 27 juil 2014 i want that date picker stop at this date and don't show 28 aout
Thank's for your help

A:

Add 1 day and 1 month to your calender instance.  And pass it to setMaxDate()
    // Set calendar to 1 day next from today
    calendar.add(Calendar. DAY_OF_MONTH, 1);
    // Set calendar to 1 month next
    calendar.add(Calendar. MONTH, 1);
    datePicker.getDatePicker().setMaxDate(calendar.getTimeInMillis());

So your method will look like 
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Calendar calendar = Calendar.getInstance();
    int yy = calendar.get(Calendar. YEAR);
    int mm = calendar.get(Calendar. MONTH);
    int dd = calendar.get(Calendar. DAY_OF_MONTH);
    DatePickerDialog datePicker = new DatePickerDialog(getActivity(), this,
            yy, mm, dd);
    datePicker.getDatePicker().setCalendarViewShown(false);
    // Set calendar to 1 day next from today
    calendar.add(Calendar. DAY_OF_MONTH, 1);
    // Set calendar to 1 month next
    calendar.add(Calendar. MONTH, 1);
    datePicker.getDatePicker().setMaxDate(calendar.getTimeInMillis());

    datePicker.setTitle("RENTRE TA DATE DE NAISSANCE."); 

    return datePicker;
}

