Skip to content

Getting a timestamp always results in 1969-12-31T16:00:02.019 #399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PermissionError opened this issue Feb 14, 2019 · 4 comments
Closed
Labels
troubleshooting waiting for feedback Waiting for a feedback from the issue creator

Comments

@PermissionError
Copy link

PermissionError commented Feb 14, 2019

I have some code where I was to store the Timestamp now (using CURRENT_TIMESTAMP) into a row, then after some time check whether a day has passed or not. Currently, the date sets just fine, and I can read the correct value with the SQLite CLI. But when using my code to get the timestamp, it always returns 1969-12-31T16:00:02.019 no matter what I set it to.

No exceptions were thrown.

My code for reading the timestamp:

ResultSet rs = DB.prepareStatement("SELECT * FROM Cooldown WHERE UUID = \"" + uuid + "\"").executeQuery();
            if(!rs.next()){
                rs.close();
                //all System.out.println calls are debug lines that I used to find where the bug occurred
                System.out.println("-1");
                return false;
            }
            LocalDateTime last = rs.getTimestamp("LastReward").toLocalDateTime();
            LocalDateTime now = LocalDateTime.now();
            System.out.println("0");
            System.out.println(rs.getTimestamp("LastReward") + " " + last.toString() + " " + now.toString());

Output:

0
1969-12-31 16:00:02.019 1969-12-31T16:00:02.019 2019-02-13T20:29:49.238
@BitCashMC
Copy link

hi

@witmoca
Copy link
Contributor

witmoca commented Feb 19, 2019

I can't seem to reproduce the problem.
Can you provide more details (such as OS, sqlite-jdbc version, jdk/jre version and vendor) and a short self contained example? A short sample that creates a table, inserts a row with timestamp and reads it again should suffice.

There is however a deviation in your results that shouldn't be there. According to the reference there shouldn't be any miliseconds reported.

The format for CURRENT_TIMESTAMP is "YYYY-MM-DD HH:MM:SS"

This has been proven time and time again (See bug #88 ) to be true.
This is where your code should break down. As rs.getTimestamp("LastReward") breaks down for a lack of those same milliseconds.

In neither case do you end up with an end of 1969 date however. The obvious 1970 epoch reference is in there, minus a few hours. So that definately isn't a coincidence.

In any case it would help to actually be able to reproduce your problem.

@gotson
Copy link
Collaborator

gotson commented Jul 28, 2022

Is this still happening on the latest version?

@gotson gotson added the waiting for feedback Waiting for a feedback from the issue creator label Jul 28, 2022
@gotson
Copy link
Collaborator

gotson commented Jan 13, 2023

Closing this as no feedback was received.

@gotson gotson closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
troubleshooting waiting for feedback Waiting for a feedback from the issue creator
Projects
None yet
Development

No branches or pull requests

4 participants