在Java中,可以通过System.currentTimeMillis()
方法来获取当前的毫秒级时间戳,然后可以将其除以1000来得到秒级时间戳。示例如下:
long currentTimeMillis = System.currentTimeMillis();
long currentSeconds = currentTimeMillis / 1000;
System.out.println("秒级时间戳:" + currentSeconds);
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:java怎么获取秒级时间戳