package com.test;
import java.sql.Timestamp;
import java.time.Instant;
public class test1 {
public static void main(String[] args) {
//Timestamp 的参数是毫秒,Instant 获得的是秒
System.out.println(new Timestamp(Instant.now().getEpochSecond()*1000L));
System.out.println(new Timestamp(Instant.now().getEpochSecond()*1000));
System.out.println(new Timestamp(Instant.now().getEpochSecond()));
System.out.println(new Timestamp(0));
//结果
// 2022-01-13 13:26:29.0
// 2022-01-13 13:26:29.0
// 1970-01-20 08:07:31.589
// 1970-01-01 08:00:00.0
}
}
JAVA Instant类型 转换 Timestamp类型 时间戳
最新推荐文章于 2024-10-16 10:13:45 发布