Using SimpleDateFormat
you can convert the date in the edittext to milliseconds.
example:
DateFormat df = new SimpleDateFormat("MM/dd/yyyy",Locale.US);
you will need to adjust the format based on how you are displaying it but after that just use the parse method from the DateFormat
object
Date d = df.parse(dateString);
then create a Calendar
object and set the date
Calendar calendar = Calendar.getInstance();
calendar.setDate(d);
Edit:
to send the text from the EditText
you need to send the string in the bundle when you create the dialogfragment
example:
DialogFragment newFragment = new DatePickerFragment();
Bundle bundle = new Bundle();
bundle.putString("dateAsText",edit_datepurchased.getText().toString());
newFragment.setArguments(bundle);
newFragment.show(getFragmentManager(), "datePicker");
then in your dialogfragment use getArguments()
to get the bundle
Bundle bundle = getArguments();
String date = bundle.getString("dateAsText");