David David - 1 year ago 63
Android Question

How to get the date from the DatePicker widget in Android?

I use a

DatePicker
widget in Android for the user to set a date, and want to get the date value when a confirm button is clicked, how can I do that?

Answer Source

Try this:

 DatePicker datePicker = (DatePicker) findViewById(R.id.datePicker1);
 int day = datePicker.getDayOfMonth();
 int month = datePicker.getMonth() + 1;
 int year = datePicker.getYear();