1、使用LocalDateTime架包
LocalDate localDate = LocalDate.now();
Timestamp timestamp= Timestamp.valueOf(LocalDateTime.now());
System.out.println(timestamp.getTime());
结果是
2、使用Instant架包
Instant instant = Instant.now();
long timeStampMillis = instant.toEpochMilli();
System.out.println(timeStampMillis);
结果是