Java Instant isAfter() method

The isAfter() method of Java Instant class is used to check if the instant is after the specified instant.

Syntax

Parameters

otherInstant- The other instant to compare to, not null.

Return

True, if this instant is after the specified instant.

Exceptions

NullPointerException - If otherInstant is null.

Example 1

Output:

The output will be like this.

Instant 1: 2017-02-03T10:37:30Z
Instant 2: 2017-03-03T10:37:30Z
Instant 1 is not after as Instant 2.

Example 2

Output:

The output will be like this.

2017-05-01T20:57:51.494Z
2016-12-03T10:15:30Z
true