String start = "9-4-2015";
String end = "11-4-2015";
SimpleDateFormat sdf = new SimpleDateFormat("d-M-yyyy");
List<IncomeModel> allToDos = db.getAllIncomesWeeks();
for (IncomeModel todo : allToDos) {
DatabaseDate = todo.getDate();
try {
if (sdf.parse(start).before(sdf.parse(end))) {
incomeModel.add(todo);
sum = sum + Integer.parseInt(todo.getAmount());
}
} catch (NumberFormatException | ParseException e) {
e.printStackTrace();
}
}
tvSum.setText(sum + "");
我需要一个开始日期和结束日期之间的记录。 我也试过这个查询
"SELECT * FROM expenses WHERE date BETWEEN '"+ start + "' AND '" + end + "'"
但它也显示错误的数据。