Java Date Time - LocalDate isBefore(ChronoLocalDate other) example








LocalDate isBefore(ChronoLocalDate other) checks if this date is before the specified date.

Syntax

isBefore has the following syntax.

public boolean isBefore(ChronoLocalDate other)

Example

The following example shows how to use isBefore.

import java.time.LocalDate;
/* w ww .j  ava2 s.  com*/
public class Main {
  public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);
    LocalDate b = LocalDate.of(2014, 7, 1);
    System.out.println(a.isBefore(b)); 
    System.out.println(a.isBefore(a)); 
    System.out.println(b.isBefore(a)); 
  }
}

The code above generates the following result.