Java Date Time - YearMonth isValidDay(int dayOfMonth) example








YearMonth isValidDay(int dayOfMonth) checks if the day-of-month is valid for this year-month.

This method checks whether this year and month and the input day form a valid date.

Syntax

isValidDay has the following syntax.

public boolean isValidDay(int dayOfMonth)

Example

The following example shows how to use isValidDay.

import java.time.YearMonth;
/* w ww . j  a  v  a2  s.  c om*/
public class Main {
  public static void main(String[] args) {
    YearMonth y = YearMonth.now();

    System.out.println(y.isValidDay(12));

  }
}

The code above generates the following result.