我在我的 android 应用程序中遇到了一些奇怪的问题,当我在 datepicker 中为 ex 选择日期时,15march2013 我得到 9october2007
这是来自魔法的片段
public static class DatePickerFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// Create a new instance of DatePickerDialog and return it
return new DatePickerDialog(getActivity(), (OnDateSetListener)getActivity(), year, month, day);
}
}
public void onDateSet(DatePicker view, int year, int month, int day) {
d.setDate(day);
d.setMonth(month);
d.setYear(year);
int flags = 0;
flags |= DateUtils.FORMAT_SHOW_DATE;
flags |= DateUtils.FORMAT_SHOW_YEAR;
String str = DateUtils.formatDateTime(this, d.getTime(), flags);
date.setText(str);
}
实际上我不知道有什么问题请帮忙!