Java MonthDay check if valid for a certain year

Description

Java MonthDay check if valid for a certain year

import java.time.Month;
import java.time.MonthDay;

public class Main {

  public static void main(String[] args) {
    MonthDay md1 = MonthDay.of(Month.DECEMBER, 25);
    MonthDay md2 = MonthDay.of(Month.FEBRUARY, 29);

    if (md2.isValidYear(2014)) {
      System.out.println(md2);/* ww  w  .j av a2 s . c o  m*/
    }else {
      System.out.println("not valid for 2014");
    }
    System.out.println(md1.getDayOfMonth());

  }
}



PreviousNext

Related