Java Date Time - MonthDay isBefore(MonthDay other) example








MonthDay isBefore(MonthDay other) checks if this month-day is before the specified month-day.

Syntax

isBefore has the following syntax.

public boolean isBefore(MonthDay other)

Example

The following example shows how to use isBefore.

import java.time.Month;
import java.time.MonthDay;
//from   ww w  .j a v  a  2s.co  m
public class Main {
  public static void main(String[] args) {
    MonthDay m = MonthDay.now();
    
    System.out.println(m.isBefore(MonthDay.of(Month.APRIL, 1)));

  }
}

The code above generates the following result.