나는 책 제목, 날짜 추가 및 책을 반환해야하는 날짜를 저장하는 앱을 만들고 있습니다. 아래에 오늘 오늘부터 2 일 사이에 반환 될 모든 책을 가져 와서 목록보기로 반환 한 where
문을 보여줍니다. 그러나 그것은 작동하지 않습니다, 내가 잘못된거야 어디 확실하지 않다 :SQlite WHERE 문이 작동하지 않습니까?
//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());
:
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);
}
이 날짜는 "기한"에 대한 입력되면 코드입니다
날짜는 모두 문자열입니다. 누구든지 도와 줄 수 있습니까?
'작동하지 않음'은 오류 또는 예기치 않은 결과를 의미합니까? – PinnyM
글타래는 목록보기에 어떤 책도 표시하지 않습니다. 그래서 예상치 못한 결과. – Ruddy