The Date type and the Android database
Posted
by cdonner
on Stack Overflow
See other posts from Stack Overflow
or by cdonner
Published on 2010-05-26T02:31:32Z
Indexed on
2010/05/26
2:41 UTC
Read the original article
Hit count: 617
I understand that SQLite stores dates as long integers. When I read rows into a cursor using the standard method (i.e. using the query() method that reads data into a cursor), the result is a date string that includes the time. If I want a different format, I have to parse the string back into a date - possible, but a bit backwards.
By using a ViewBinder (as suggested in this question), I can pretty much do anything I want, but the date is already a string at the time the method executes.
The accepted answer to the above question also suggests that storing dates as longs would help avoid this problem. I don't want to do that, just in case I want to interpret my data with something else than this application. Maybe I want to expose it via a provider.
Is there a way to handle this in the database adapter instead, i.e. controlling the date format that the cursor contains, so that I don't have to change the schema, and don't have to parse the default output back into a Date type?
© Stack Overflow or respective owner