Year of() method in Java with Examples Last Updated : 27 Nov, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: 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); } } Output: 2018 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); } } Output: 1997 Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#of-int- Comment More infoAdvertise with us Next Article Year with() Method in Java with Examples B barykrg Follow Improve Article Tags : Misc Java Java-Functions Java-time package Java-Year +1 More Practice Tags : JavaMisc Similar Reads Year now() method in Java with examples The now() method of Year class in Java is used to return the current year from the system clock in the default time-zone. Syntax: public static Year now() or, public static Year now(Clock clock) or, public static Year now(ZoneId zone) Parameter: The parameter is optional for this method as shown in 2 min read Year with() Method in Java with Examples In Year class, there are two types of with() method depending upon the parameters passed to it. with(TemporalAdjuster adjuster) with(TemporalAdjuster adjuster) method of the Year class used to adjusted this Year using TemporalAdjuster and after adjustment returns the copy of adjusted Year.The adjust 3 min read Year until() Method in Java with Examples until() method of the Year class used to calculate the amount of time between two Year objects using TemporalUnit. The start and end points are this and the specified Year passed as a parameter. The result will be negative if the end is before the start. The calculation returns a whole number, repre 2 min read Year query() Method in Java with Examples query() method of an Year class used to query this Year using the specified query as parameter.The TemporalQuery object passed as parameter define the logic to be used to obtain the result from this Year. Syntax: public <R> R query(TemporalQuery<R> query) Parameters: This method accepts 2 min read Year range() method in Java with Examples range() method of the Year class is used to get the range of field in terms of the minimum and maximum values and the field is passed as a parameter to this method. The returned value for this method is ValueRange object for the field and the method returns ValueRange object only for those fields wh 2 min read Year toString() method in Java with Examples The toString() method of Year class in Java is used to return the string representation of this Year object. Syntax: public String toString() Parameter: This method does not accepts any parameter. Return Value: It returns the string representation of this Year object. Below programs illustrate the t 1 min read Like