Year length() method in Java with Examples Last Updated : 27 Nov, 2018 Comments Improve Suggest changes Like Article Like Report The length() method of Year class in Java is used to return the length of this year object's value in number of days. There can be only two possible lengths of Year, 365(Non-leap years) and 366(Leap years). Syntax: public int length() Parameter: This method does not accepts any parameter. Return Value: It returns an integer value denoting the length of Year in number of days. Below programs illustrate the length() method of Year in Java: Program 1: Java // Program to illustrate the length() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create a Year object Year thisYear = Year.of(2016); // Print the length of this year in Number // of days, 366 in this case as 2016 is // a Leap Year System.out.println(thisYear.length()); } } Output: 366 Program 2: Java // Program to illustrate the length() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create a Year object Year thisYear = Year.of(1990); // Print the length of this year in Number // of days, 365 in this case as 1990 is not // a Leap Year System.out.println(thisYear.length()); } } Output: 365 Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#length-- Comment More infoAdvertise with us Next Article Year length() 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 YearMonth lengthOfYear() method in Java with Examples The lengthOfYear() method of YearMonth class in Java is used to return the length of year of this year-month object's value in number of days. The value of the length of a year is either 365 or 366 based on whether the Year is leap or not. Syntax: public int lengthOfYear() Parameter: This method doe 2 min read Year of() method in Java with Examples 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 1 min read 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 get() method in Java with Examples get() method of the Year class used to get the value for the specified field passed as parameter from this Year as an integer value. This method queries this year for the value of the field and the returned value will always be within the valid range of values for the field. When the field is not su 2 min read Year from() Method in Java with Examples from() method of the Year class used to get instance of Year from TemporalAccessor object passed as parameter. A TemporalAccessor represents an arbitrary set of date and time information and this method helps to get a year object based on the specified TemporalAccessor object. Syntax: public static 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 plus(long,unit) method in Java with Examples The plus(long, unit) method of Year class is used to return a copy of this year after adding the specified amount of unit to this Year object.An exception is thrown, If the specified unit cannot be added to this Year object. This instance is immutable and unaffected by this method call. Syntax: publ 2 min read Like