要获取系统时间的 13 位时间戳,可以使用 Java 的 System.currentTimeMillis() 方法,该方法返回自 1970 年 1月 1 日 0 时 0 分 0 秒以来的毫秒数。

以下是获取系统时间的 13 位时间戳的示例代码:

public class Main {
    public static void main(String[] args) {
        long timestamp = System.currentTimeMillis();
        System.out.println(timestamp);
    }
}

输出结果类似于:

1622140537542

注意,System.currentTimeMillis() 返回的是一个 long 类型的值,需要使用 long 类型的变量来保存时间戳。


原文地址: https://www.cveoy.top/t/topic/p5ex 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录