Java Timestamp toInstant() 方法

2025年3月25日 | 1 分钟阅读

Timestamp 类的 toInstant() 方法将 Timespan 对象转换为 Instant,它表示与此 Timestamp 相同的时间点。

语法

参数

不适用

返回值

Timestamp 类的 toInstant() 方法返回一个 Instant,它表示与此 Timestamp 相同的时间点。

覆盖

Timestamp 类的 toInstant() 方法覆盖了

Date 类中的 toInstant() 方法

示例 1

输出

Timestamp : 2018-09-01 09:01:15.0
Instant Timespan : 2018-09-01T03:31:15Z

示例 2

输出

Timestamp : 2018-09-06 11:59:02.683
Current instant Timespan : 2018-09-06T06:29:02.683Z