David David - 5 months ago 21
Android Question

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

I use a

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?


Try this:

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