My current question is about how does ROOM database manages dates and timestamps? Working on my current project, I’ve just found out that if I store my date fields as Strings (yyyy-mm-dd to be more precise), I won’t be able to make queries in which I compare the date fields because ROOM does not know how to work with Strings. To be more precise I would like to be able to make queries in which I get all the entries in a table between a start date and an end date currently stored as Strings. I’ve looked into the documentation:
Referencing complex data with Room
and found out the solution is to use TypeConverters and annotate your specific entities accordingly. However both the documentation and some stack overflow answers:
Room using date field
Type converter for String date to long
seem to focus solely on the case of converting from Long to Date and viceversa. I understand the case, but my specific scenario is that I introduce the transaction dates for instance, in the database by hand as Strings. I would like to know a method of converting those Strings in format yyyy-mm-dd to Long and then I could use the other hints.
Any help would be appreciated.
6