YearMonth isValidDay(int dayOfMonth) example

Description

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;
/*from   ww w  . j  a v  a  2  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.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset