Question: How to Disable future dates in Android date picker

Java Code :

```
mExpireDate.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                // To show current date in the datepicker
                final Calendar mcurrentDate = Calendar.getInstance();
                int mYear = mcurrentDate.get(Calendar.YEAR);
                int mMonth = mcurrentDate.get(Calendar.MONTH);
                int mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);

                 DatePickerDialog mDatePicker = new DatePickerDialog(
                        EventRegisterActivity.this, new OnDateSetListener() {
                            public void onDateSet(DatePicker datepicker,
                                    int selectedyear, int selectedmonth,
                                    int selectedday) {

                                mcurrentDate.set(Calendar.YEAR, selectedyear);
                                mcurrentDate.set(Calendar.MONTH, selectedmonth);
                                mcurrentDate.set(Calendar.DAY_OF_MONTH,
                                        selectedday);
                                SimpleDateFormat sdf = new SimpleDateFormat(
                                        getResources().getString(
                                                R.string.date_card_formate),
                                        Locale.US);

                                mExpireDate.setText(sdf.format(mcurrentDate
                                        .getTime()));
                            }
                        }, mYear, mMonth, mDay);

                mDatePicker.setTitle(getResources().getString(
                        R.string.alert_date_select));
                mDatePicker.show();
            }
        });

```

How to do it?

Answer: 
You can call getDatePicker().setMaxDate(long) on your DatePickerDialog to set today as your maximum date. You can update the function with the same name from the snippet you posted.

Note:: DatePickerDialog is the object that I referenced in the Android Docs from the link I posted.

```
@Override
protected Dialog onCreateDialog(int id) {
    Calendar c = Calendar.getInstance();
    int cyear = c.get(Calendar.YEAR);
    int cmonth = c.get(Calendar.MONTH);
    int cday = c.get(Calendar.DAY_OF_MONTH);
    switch (id) {
        case DATE_DIALOG_ID:
        //start changes...
        DatePickerDialog dialog = new DatePickerDialog(this, mDateSetListener, cyear, cmonth, cday);
        dialog.getDatePicker().setMaxDate(System.currentTimeMillis());
        return dialog;
        //end changes...
    }
    return null;
}

```

Try this and give your feedback!!!
```
 // Custom Your Future Dates  

 // Example for today and next 3 days :- 3(NUMBER OF NEXT DAYS)*24*60*60*1000l

 // As 24 represents hrs in day

 // As 60 mins 60 secs and convert it to millisec

 //Inside Class which implements DatePickerDialog.OnDateSetListener
 private Calendar mCurrentDate;

 //Inside OnCreate Method
 mDateEditText.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {

   mCurrentDate = Calendar.getInstance();
   int year = mCurrentDate.get(Calendar.YEAR);
   int month = mCurrentDate.get(Calendar.MONTH);
   int day = mCurrentDate.get(Calendar.DAY_OF_MONTH);

   DatePickerDialog mDatePickerDialog = new DatePickerDialog(this, this, year, month, day);
   mDatePickerDialog.getDatePicker().setMaxDate(System.currentTimeMillis() + 3 * 24 * 60 * 60 * 1000 l);
  }
 });

 @Override
 public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
  mDateEditText.setText(dayOfMonth + "/" + month + "/" + year);

 }

```