本のタイトル、追加日、本を返却する必要がある日付を保存するアプリを作成しています。以下に、where
今日の日付から 2 日後までに返却予定のすべての本をリストビューとして返すステートメントを示します。ただし、機能しません。どこが間違っているのかわかりません。
public Cursor fetchAllDue() {
//get todays date
Calendar cal=Calendar.getInstance();
int currentDay=cal.get(Calendar.DAY_OF_MONTH);
//Add days on to todays date
cal.set(Calendar.DAY_OF_MONTH, currentDay+2);
cal.getTime(); //Result
//format back to string
String formattedDate = new SimpleDateFormat("dd-MM-yyyy HH:mm").format(cal.getTime());
//get todays date
Calendar cal1=Calendar.getInstance();
int currentDay1=cal1.get(Calendar.DAY_OF_MONTH);
//Atodays date
cal1.set(Calendar.DAY_OF_MONTH, currentDay1);
cal1.getTime(); //Result
//format back to string
String formattedDate1 = new SimpleDateFormat("dd-MM-yyyy HH:mm").format(cal1.getTime());
//body = date added, needs to be changed
return mDb.query(DATABASE_TABLE, new String[] { KEY_ROWID, KEY_TITLE,
KEY_BODY, KEY_EXTRA, KEY_DUE }, KEY_DUE + " BETWEEN 'formattedDate1' and 'formattedDate2'", null, null, null, null);
}
これは、「期日」に日付を入力するときのコードです。
//convert string to int.
int myNum = Integer.parseInt(editbox3.getText().toString());
//get todays date
Calendar cal=Calendar.getInstance();
int currentDay=cal.get(Calendar.DAY_OF_MONTH);
//Add days on to todays date
cal.set(Calendar.DAY_OF_MONTH, currentDay+myNum);
cal.getTime(); //Result
//formate back to string
String formattedDate = new SimpleDateFormat("dd-MM-yyyy HH:mm").format(cal.getTime());
bundle.putString(NotesDbAdapter.KEY_DUE,formattedDate
.toString());
日付はすべて文字列です。誰でも助けることができますか?