Year now() method in Java with examples Last Updated : 27 Nov, 2018 Comments Improve Suggest changes Like Article Like Report 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 the above syntax. Return Value: It returns the current year from the system clock in the default time-zone if no parameter is specified otherwise it uses the specified clock and time zone to return the current year. It can never return a NULL value Below program illustrate the length() method of Year in Java: Program 1: Java // Program to illustrate the now() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create a Year object using now() method // It will return the current year from the // system clock in the default time-zone. Year thisYear = Year.now(); // Print the year object System.out.println(thisYear); } } Output: 2018 Program 2: If a clock is specified as a parameter to the now() method. In that case, it will use the default time zone but not the system clock, it will instead use the clock passed as parameter to it in the default time-zone. Java // Program to illustrate the now() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create a Year object using now() method // It will return the current year from the // clock specified in the default time-zone. Year thisYear = Year.now(Clock.systemUTC()); // Print the year object System.out.println(thisYear); } } Output: 2018 Program 3: If a zone is specified as a parameter to the now() method. In that case, it will not use the default time zone, it will instead use the system-clock in the time-zone provided as a parameter to it. Java // Program to illustrate the now() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create a Year object using now() method // It will return the current year from the // system-clock in the time-zone specified Year thisYear = Year.now(ZoneId.systemDefault()); // Print the year object System.out.println(thisYear); } } Output: 2018 Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#now-- Comment More infoAdvertise with us Next Article Year now() 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 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 YearMonth now() method in Java with Examples The now() method of the YearMonth class in Java is used to obtain the current year-month from the system clock in the default time-zone. Syntax: public static YearMonth now() Parameters: This method does not accept any parameter. Return value: This method returns the current year-month using the sys 1 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 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 Like