Home java System.CurrentTimeMillis () gives the wrong result

System.CurrentTimeMillis () gives the wrong result

Author

Date

Category

Good day!

System.CurrentTimeMillis () in java gives the wrong result.

That is, by logs, it gives 1569633070510 , which is not reality.
But if you cut on the last three numbers (510) , the result becomes reliable.

Tell me, please, where does he take these extra numbers and how can I remove them?


Answer 1, Authority 100%

This is milliseconds. Only you confused them with seconds.

1569633070510 / 1000/3600/24/365.25 = 49.74 (almost 50 years from January 1, 1970)

Answer 2

Use the java.sql.date :

date currentdate = new date (System.CurrentTimemillis ());

translates to the current date – everything should be even ..

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions