Java Instant equals() 方法

7 Jan 2025 | 1 分钟阅读

Java Instant 类的 equals() 方法用于检查此 Instant 是否等于指定的 Instant。

语法

参数

otherInstant - 另一个 Instant,null 返回 false。

返回

如果 otherInstant 等于此 Instant,则返回 true,否则返回 false。

示例 1

输出

输出将如下所示。

Instant 1: 2018-08-18T10:37:30Z
Instant 2: 2018-08-18T10:37:30Z
Instant 2 is not same as Instant 1.

示例 2

输出

false