LocalDateTime isBefore(ChronoLocalDateTime> other) example
Description
LocalDateTime isBefore(ChronoLocalDateTime<?> other)
checks if this date-time is before the specified date-time.
Syntax
isBefore
has the following syntax.
public boolean isBefore(ChronoLocalDateTime<?> other)
Example
The following example shows how to use isBefore
.
import java.time.LocalDateTime;
//from w w w .j a va 2s . c o m
public class Main {
public static void main(String[] args) {
LocalDateTime a = LocalDateTime.of(2012, 6, 30, 12, 00);
LocalDateTime b = LocalDateTime.of(2012, 7, 1, 12, 00);
System.out.println(a.isBefore(b));
System.out.println(a.isBefore(a));
}
}
The code above generates the following result.