The Room database implements the Task class with date/time fields.
@ColumnInfo(name = TaskEntry.COLUMN_CREATE_DATE)
@TypeConverters({LocalDateTimeConverter.class, LDateTimeConverter.class})
private LocalDateTime createDate;
@ColumnInfo(name = TaskEntry.COLUMN_FINISH_DATE)
@TypeConverters({LocalDateTimeConverter.class, LDateTimeConverter.class})
private LocalDateTime finishDate;
A function is implemented for selecting tasks that are available today and not completed, but its results are ignored and a full list of tasks is issued without a range of selected dates.
@Query("Select * from " TaskEntry.TABLE_NAME
" where (" TaskEntry.COLUMN_CREATE_DATE " >= :startDayTime"
" or " TaskEntry.COLUMN_FINISH_DATE " < :endDayTime)"
" and " TaskEntry.COLUMN_FINISHED " = 0")
LiveData<List<Task>> getLiveDailyTasks(Long startDayTime, Long endDayTime);
There is a suspicion that this method of comparison through conversion does not work, but how then can this still be implemented?
CodePudding user response:
There is a suspicion that this method of comparison through conversion does not work
Run the App from Android Studio. Whilst awaiting user input after accessing the database then use App Inspection. Look at the TaskEntry table are values stored as expected? If so then odds on the TypeConverters are working.
Next click on the Open new Query icon (table with looking glass) then visit you DAO class and click on the same icon along side the @Query in question, input suitable value(s) and click run. If the data displays as expected then the query is fine, so look at the LiveData aspect.
Here's a sort of demo via screen shots (obviously with a different App and databases but with time stores as a long to a precision of seconds):-
after clicking run :-