VOOZH about

URL: https://www.geeksforgeeks.org/java/year-of-method-in-java-with-examples/

⇱ Year of() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Year of() method in Java with Examples

Last Updated : 27 Nov, 2018
The of() method of Year class in Java is used to return an Year instance. It accepts an year according to the proleptic ISO calendar system and returns an instance of Year with the specified isoYear. Syntax:
public static Year of(int isoYear)
Parameter: It accepts a single integral value isoYear as the only parameter according to the proleptic ISO calendar system. Return Value: It returns an instance of Year. Exception: It throws DateTimeException if the year passed as argument is found to be invalid according to the proleptic ISO calendar system. Below programs illustrate the length() method of Year in Java: Program 1:
Output:
2018
Program 2:
Comment