How can I get seconds from 1970 in java ?
+10
A:
You mean epoch time? You can use
long epoch = (System.currentTimeMillis()/1000L);
that will get the number of seconds since January 1st 1970 UTC time.
this belongs on StackOverflow though, it will be moved there shortly so please don't repost.
John T
2010-01-26 19:23:15
Voting you up for a more complete answer:)
phoebus
2010-01-26 21:59:34
You should divide by 1000L rather than 1000 to avoid unecessary casting.
Adamski
2010-01-26 22:32:22
@Adamski haven't used java in a while, I only program now for making personal tasks faster :) Thanks for the heads up.
John T
2010-01-27 18:23:58