且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Java 中将时间戳转换为日期?

更新时间:2023-01-22 11:49:43

只需创建一个新的 Date 对象,并将图章的 getTime() 值作为参数.

Just make a new Date object with the stamp's getTime() value as a parameter.

这是一个例子(我使用了当前时间的示例时间戳):

Here's an example (I use an example timestamp of the current time):

Timestamp stamp = new Timestamp(System.currentTimeMillis());
Date date = new Date(stamp.getTime());
System.out.println(date);