Проверьте это
class MyDataPicker extends DatePickerDialog{
int year, monthOfYear, dayOfMonth;
final Calendar c;
Date d1;
public MyDataPicker(Context context, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth){
super(context, callBack, year, monthOfYear, dayOfMonth);
this.year=year; this.monthOfYear=monthOfYear; this.dayOfMonth=dayOfMonth;
d1= new Date(year, monthOfYear, dayOfMonth);
c = Calendar.getInstance();
// TODO Auto-generated constructor stub
}
public void onDateChanged(DatePicker datepicker, int year, int month, int day){
long timeinmilies = d1.getTime();
Date d = new Date(year, month,day);
long millis = d.getTime();
if(millis<=timeinmilies){
this.year = year; this.monthOfYear = month; this.dayOfMonth = day;
}
datepicker.updateDate(this.year, monthOfYear, dayOfMonth);
super.onDateChanged(datepicker,this.year, monthOfYear, dayOfMonth);
}
}
private DatePickerDialog.OnDateSetListener myDateSetListener
= new DatePickerDialog.OnDateSetListener(){
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
// TODO Auto-generated method stub
// set Date in EditText or textView Here
DOB.setText((monthOfYear+1)+"-"+dayOfMonth+"-"+year);
}
};
// button click to open datepicker
public void onClickPickDate(View view){
final Calendar c = Calendar.getInstance();
int myYear = c.get(Calendar.YEAR);
int myMonth = (c.get(Calendar.MONTH));
int myDay = c.get(Calendar.DAY_OF_MONTH);
MyDataPicker datePickerDialog = new MyDataPicker(this,myDateSetListener,myYear, myMonth, myDay);
datePickerDialog.show();
}