Java Instant equals() method

The equals () method of Java Instant class is used to check if this instant is equal to the specified instant.

Syntax

Parameters

otherInstant - The other instant, null returns false.

Return

True, if the other instant is equal to this one, else false.

Example 1

Output:

The output will be like this.

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

Example 2

Output:

false