Java – get the date representation in seconds?

I'm using an API that requires a date parameter as the number of seconds, an int

My problem is that I now store this time in Java util. In date, I want to know if there are any methods to convert Java util. The date variable is converted to seconds so that I can apply it to the int parameter required by the API?

Solution

import java. util. Date;

… long secs =(new Date(). getTime())/ 1000; …

See – http://docs.oracle.com/javase/6/docs/api/java/util/Date.html#getTime ()

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>