数小时的梳理之后,解决方案是给定答案和其他一些事项的组合:
// variables declared
private int mYear;
private int mMonth;
private int mDay;
// datepicker declared and listened for
private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
updateDisplay();
}
};
// converting the datestring from the picker to a long:
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_MONTH, mDay);
c.set(Calendar.MONTH, mMonth);
c.set(Calendar.YEAR, mYear);
Long lDate = c.getTime().getTime();
//The formatting that worked on the trip back from long to string
// (I spent hours with SimpleDateFormat strings, years that were off by 1500, etc.):
String DateFormatted = DateFormat.getDateFormat(getApplicationContext()).format(helper.getDate(c)); // helper.getDate(c) is just the passing back of the Long date from my SELECT statement
该论坛的新手-我试图将其投票为有用的,但我的信誉点还不够.