Date Picker Dialog

suggest change

It is a dialog which prompts user to select date using DatePicker. The dialog requires context, initial year, month and day to show the dialog with starting date. When the user selects the date it callbacks via DatePickerDialog.OnDateSetListener.

public void showDatePicker(Context context,int initialYear, int initialMonth, int initialDay) {
       DatePickerDialog datePickerDialog = new DatePickerDialog(context,
                new DatePickerDialog.OnDateSetListener() {
                    public void onDateSet(DatePicker datepicker,int year ,int month, int day) {
                    //this condition is necessary to work properly on all android versions
                            //You now have the selected year, month and day

                }, initialYear, initialMonth , initialDay);

        //Call show() to simply show the dialog;


Please note that month is a int starting from 0 for January to 11 for December

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents