请参考下图:
上面的文字说 Thu, Oct 28, 1909...而 datepicker 实际上的值是 3rd jan, 1902。错误是什么?
这是我的代码:
@SuppressWarnings("deprecation")
public void setTheDate(View v){
showDialog(DATE_DIALOG_ID);
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
// set date picker as current date
return new DatePickerDialog(this, datePickerListener,
year, month,day);
}
return null;
}
private DatePickerDialog.OnDateSetListener datePickerListener
= new DatePickerDialog.OnDateSetListener() {
// when dialog box is closed, below method will be called.
public void onDateSet(DatePicker view, int selectedYear,
int selectedMonth, int selectedDay) {
year = selectedYear;
month = selectedMonth;
day = selectedDay;
System.out.println("date" + year + month + day);
}
};
DATE_DIALOG_ID 是最终常量,我在单击按钮时调用 setTheDate() 方法。
我究竟做错了什么?