Java Date Time - MonthDay isBefore(MonthDay other) example

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


isBefore has the following syntax.

public boolean isBefore(MonthDay other)


The following example shows how to use isBefore.

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


The code above generates the following result.