I try to insert a datetime into a sqlite DB from Java, but things are weird.
When I use the code Calendar.getInstance().getTime() to insert, the value in table is (for example) 1359960520718.
When I use the the string 2010-01-01 to insert into the table, the value is normal: 2010-01-01.
But when I use the string 2010-21-51 to insert into the table, the value in the table is 2010-21-51. That’s an invalid date.
What’s wrong with it?
This is because SQLite is dynamically typed. You can write value of any type into any column, and it won’t complain – it may silently store it in different type.
According to documentation, datetime can be stored as
In your case, SQLite was unable to convert invalid date into INTEGER format, and was forced to store it as standard string instead. This date is invalid, but SQLite does not care.