Close

Java Date Time - Instant.isBefore() Examples

Java Date Time Java Java API 


Class:

java.time.Instant

java.lang.Objectjava.lang.Objectjava.time.Instantjava.time.Instantjava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public boolean isBefore(Instant otherInstant)

Checks if this instant is before the specified instant.


Examples


package com.logicbig.example.instant;

import java.time.Instant;

public class IsBeforeExample {

public static void main(String... args) {
Instant i = Instant.now();
System.out.println(i);

Instant i2 = Instant.parse("2016-12-03T10:15:30.00Z");
System.out.println(i2);

boolean b = i.isBefore(i2);
System.out.println(b);
}
}

Output

2017-05-01T20:57:49.381Z
2016-12-03T10:15:30Z
false




See Also