I am a bit confusing about how to store date $ time in SQLite database in Android. I need to store current date & time in my database table.
so:
1) Which type to use when creating date/time column in my table? 2) How to get current date/time and store it into database table according to the column type chosen?
Regarding point 1) some people says to use a text type, some others to int and some others to datetime..... but SQLite 3 recommends storing date/time as below:
I cannot see that SQLite supports datetime type. The only types supported by SQLite are: null, integer, real, text and blob (so datetime is not listed here).
so I do not understand why here
it says to use DATETIME as column type and set default value as DEFAULT CURRENT_TIMESTAMP when creating database table.
Storing it as milliseconds, the problem is that timezone is lost. In this case it is said to save that separately and I do not kwnow how to get rid of this...
Regarding point 2), I think of several ways.... using DATETIME('now') or System.currentTimeMillis()... but I do not know if it is the best way....
How can I get rid of this?