0

i am new in the android development. i want show the date picker in the tablet. when user click on it a popup will come with date picker. its currently working properly with the below code

 DatePickerDialog dialog1 = new DatePickerDialog(RegistrationCompanyStep2Activity.this,new OnDateSetListener() {
                        @Override
                        public void onDateSet(DatePicker view, int year,int monthOfYear, int dayOfMonth) 
                        {

                            yearExpiration = year;
                            monthExpiration = monthOfYear + 1;
                            dayExpiration = dayOfMonth;
                            spinCompanyEstablished.setText(String.valueOf(yearExpiration)+ "-"+ String.format("%02d", monthExpiration)+ "-" + String.format("%02d", dayExpiration));
                            editCompanyTypeID.requestFocus();
                            openKeyBoard(editCompanyTypeID);
                        }
                    }, yearExpiration, monthExpiration, dayExpiration);
            dialog1.show();   

Now i want to put some limitation in this. Like user cant select the future date so can you tell me what changes i have to do to fulfill my requirements ?

Thanks in advance

deck john
  • 637
  • 1
  • 9
  • 22

2 Answers2

1

you can use

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

0

use this dialog1.getDatePicker().setMaxDate(System.currentTimeMillis());

Lingeshwaran
  • 22
  • 1
  • 8