Android获取当前时间戳?

2022-01-13 00:00:00 timestamp epoch android kotlin java

我想像这样获取当前时间戳:1320917972

I want to get the current timestamp like that : 1320917972

int time = (int) (System.currentTimeMillis());
Timestamp tsTemp = new Timestamp(time);
String ts =  tsTemp.toString();

推荐答案

解决办法是:

Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();

相关文章