以秒为单位获取日期表示? [英] Get date representation in seconds?
本文介绍了以秒为单位获取日期表示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的API需要一个日期参数作为秒数, int
。
I am using an API which requires a date parameter as a number of seconds, an int
.
我的问题是我目前将这次存储在 java.util.date
中,我想知道是否有某种方法将 java.util.date
变量转换为秒,以便我可以将它放入 int
参数中API需要?
My problem is that I currently store this time in java.util.date
and I was wondering if there is some way to convert the java.util.date
variable to seconds so that I can fit it into the int
parameter which the API requires?
推荐答案
import java.util.Date;
import java.util.Date;
...
long secs =(new Date()。getTime())/ 1000;
...
... long secs = (new Date().getTime())/1000; ...
请参阅 - http://docs.oracle.com/javase/6/docs/api/java/util/Date.html#getTime()
这篇关于以秒为单位获取日期表示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文