VOOZH about

URL: https://www.geeksforgeeks.org/java/monthday-isvalidyear-method-in-java-with-examples/

⇱ MonthDay isValidYear() Method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

MonthDay isValidYear() Method in Java with Examples

Last Updated : 10 Apr, 2023

isValidYear() method of the MonthDay class used to check if the specified year is valid for this month-day.This can only return false for February 29th. Syntax:

public boolean isValidYear?(int year)

Parameters: This method accepts one parameter year which is the year to validate. Return value: This method returns boolean value true if the year is valid for this month-day. Below programs illustrate the isValidYear() method: Program 1: 

Output:
Year 2012 is valid for monthday: --10-12 = true

Program 2: 

Output:
Year 2017 is valid for monthday: --02-29 = false

References: https://docs.oracle.com/javase/10/docs/api/java/time/MonthDay.html#isValidYear(int)

Comment