Я пытаюсь получить данные за текущую неделю и месяц в комнате. Я создал запрос на текущий день, и он работает, но другие не работают.
Дневной запрос (этот работает):
@Query("SELECT * FROM expense_table WHERE day = strftime('%d', 'now')")
LiveData<List<Expense>> getExpensesDay();
Неделя:
@Query("SELECT * FROM expense_table WHERE week = strftime('%W', 'now')")
LiveData<List<Expense>> getExpensesWeek();
Месяц:
@Query("SELECT * FROM expense_table WHERE month = strftime('%m', 'now')")
LiveData<List<Expense>> getExpensesMonth();
Организация:
@Entity(tableName = "expense_table")
public class Expense {
@PrimaryKey(autoGenerate = true)
private int expenseId;
private String note;
private Double value;
private String type;
private Long dateLong = System.currentTimeMillis();
private String date = new SimpleDateFormat("MM/yyyy").format(new Date(dateLong));
private static Calendar cal = Calendar.getInstance();
private int month = cal.get(Calendar.MONTH);
private int week = cal.get(Calendar.WEEK_OF_YEAR);
private int day = cal.get(Calendar.DAY_OF_MONTH);
private int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
private String weekDay = new DateFormatSymbols().getWeekdays()[dayOfWeek];