SQLite CURRENT_TIMESTAMP always 1970-01-01

I have the following table definition:

CREATE TABLE players(playerid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(20) NOT NULL UNIQUE, added DATETIME DEFAULT CURRENT_TIMESTAMP); 

CURRENT_TIMESTAMP tirelessly inserts 1970-01-01 . I am poorly aware of the significance of this date and how some timestamps are positive / negative deviations from it; however, from what I read elsewhere , my default timestamp should use the current time / date, as suggested. Also, if the timestamp does not include time (since 1970 or otherwise)?

Thanks!:)

+4
source share
1 answer

I just had an epiphany and realized that I was an idiot. I use Java to connect to the database and used resultSet.getDate("added") , which, apparently, is not suitable for this purpose, and returns 1970-01-01 . getString("added") confirmed my error and returned exactly what I wanted to see :)

+4
source

Source: https://habr.com/ru/post/1402968/


All Articles