David David - 1 year ago 107
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?

Answer Source

Try this:

 DatePicker datePicker = (DatePicker) findViewById(R.id.datePicker1);
 int day = datePicker.getDayOfMonth();
 int month = datePicker.getMonth() + 1;
 int year = datePicker.getYear();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download