Java Date Time - Year isBefore(Year other) example








Year isBefore(Year other) checks if this year is before the specified year.

Syntax

isBefore has the following syntax.

public boolean isBefore(Year other)

Example

The following example shows how to use isBefore.

import java.time.Year;
/*www. j av a2  s.  co m*/
public class Main {
  public static void main(String[] args) {
    
    Year y = Year.of(2014);

    System.out.println(y.isBefore(Year.of(2015)));

  }
}

The code above generates the following result.