开发者

Getting time in Java

开发者 https://www.devze.com 2022-12-17 23:39 出处:网络
How can I get seconds 开发者_如何学JAVAfrom 1970 in Java?You mean epoch time? You can use long epoch = (System.currentTimeMillis()/1000L);

How can I get seconds 开发者_如何学JAVAfrom 1970 in Java?


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.


java.lang.System.currentTimeMillis() gives you the time since Jan 1, 1970 in milliseconds. Just divide by 1000 to get the time in seconds.

0

精彩评论

暂无评论...
验证码 换一张
取 消