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 systemand returns an instance of Year with the specified isoYear.
Syntax:
public static Year of(int isoYear)Parameter
: It accepts a single integral value
isoYearas 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:
Java
// Program to illustrate the of() method
import java.util.*;
import java.time.*;
public class GfG {
public static void main(String[] args)
{
// Create a valid Year object
// using of() method
Year thisYear = Year.of(2018);
// Print the year object
System.out.println(thisYear);
}
}
Program 2
:
Java
// Program to illustrate the of() method
import java.util.*;
import java.time.*;
public class GfG {
public static void main(String[] args)
{
// Create a valid Year object
// using of() method
Year thisYear = Year.of(1997);
// Print the year object
System.out.println(thisYear);
}
}
Reference
:
https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#of-int-RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4