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.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset