我必须在 sqlite db 中输入日期。我得到错误,我不明白为什么。有人能帮我吗?
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd" );
String strDate = sdf.format( dateAndTime );
cv.put(MyTable.DATE, strDate);
这是错误:
Caused by: java.lang.IllegalArgumentException
at java.text.DateFormat.format(DateFormat.java:361)
at java.text.Format.format(Format.java:93)
Caused by: java.lang.IllegalArgumentException
at java.text.DateFormat.format(DateFormat.java:361)
at java.text.Format.format(Format.java:93)
这是我的日期选择器:
public void chooseDate(View v) {
new DatePickerDialog(Movimenti.this, d,
dateAndTime.get(Calendar.YEAR),
dateAndTime.get(Calendar.MONTH),
dateAndTime.get(Calendar.DAY_OF_MONTH))
.show();}
private void updateLabel() {
mDataScelta.setText(fmtDateAndTime
.format(dateAndTime.getTime()));
}
DatePickerDialog.OnDateSetListener d=new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
dateAndTime.set(Calendar.YEAR, year);
dateAndTime.set(Calendar.MONTH, monthOfYear);
dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateLabel();
}
};