[Solved] Date-picker in android studio by clicking button


You can do like this.

public void setDate(View v) {
    final Calendar c = Calendar.getInstance();
    year = c.get(Calendar.YEAR);
    month = c.get(Calendar.MONTH);
    day = c.get(Calendar.DAY_OF_MONTH);
    DatePickerDialog dpd = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthofyear, int dayofmonth) {
            e5.setText(dayofmonth + "-" + monthofyear + "-" + year);
        }
    }, year, month, day);
    dpd.show();
}

Exchange the positions of day and year.
Hope to help you.

solved Date-picker in android studio by clicking button