Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java currentTimeMillis() conversion to seconds not working?

Im trying to convert milliseconds to seconds with System.currentTimeMillis();

System.out.println((int) System.currentTimeMillis() / 1000);

The output is 730750 and increasing by 1. How can i get seconds starting from 0?

**UPDATE: Now i understand the problem and thank you for answering it.

like image 240
Mert Karakas Avatar asked Sep 11 '26 12:09

Mert Karakas


1 Answers

System.currentTimeMillis() is from January 1, 1970. It will take today's time and subtract it from midnight January 1, 1970. That is why it is so many seconds.

like image 161
brso05 Avatar answered Sep 14 '26 01:09

brso05



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!