Java currentTimeMillis() conversion to seconds not working?

Mert Karakas picture Mert Karakas · Dec 8, 2014 · Viewed 9.9k times · Source

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.

Answer

brso05 picture brso05 · Dec 8, 2014

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.