Java Date Time - LocalDateTime isBefore (ChronoLocalDateTime other)








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  ww .  ja v a  2s.  com*/
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.