Java Date Time - Year isValidMonthDay(MonthDay monthDay) example








Year isValidMonthDay(MonthDay monthDay) checks if the month-day is valid for this year.

Syntax

isValidMonthDay has the following syntax.

public boolean isValidMonthDay(MonthDay monthDay)

Example

The following example shows how to use isValidMonthDay.

import java.time.Month;
import java.time.MonthDay;
import java.time.Year;
//  www  .j ava2  s  . co  m
public class Main {
  public static void main(String[] args) {
    Year y = Year.of(2014);
    
    System.out.println(y.isValidMonthDay(MonthDay.of(Month.APRIL,1)));

  }
}

The code above generates the following result.