我有一个DatePickerDialog,它显示所有正确的内容并选择正确的值。但是我想设置月份名称为Ex。 “ Jan”代替M01。
请参见下图:
https://drive.google.com/file/d/1mhWPCPkARY4I1dvYZ6RdrXueUhHvMa4b/view
查看代码:
public void setDueDate() {
if (mYear == 0) {
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
}
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, final int year,
final int monthOfYear, final int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
String strDate = mYear + "-" + (mMonth + 1) + "-" + mDay;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = format.parse(strDate);
tvDueDate.setText(format.format(date));
} catch (ParseException e) {
e.printStackTrace();
}
}
}, mYear, mMonth, mDay);
datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis());
datePickerDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
datePickerDialog.setTitle("");
datePickerDialog.show();
}