Year toString() method in Java with Examples Last Updated : 27 Nov, 2018 Comments Improve Suggest changes Like Article Like Report 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 toString() method of Year in Java: Program 1: Java // Program to illustrate the toString() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create a valid Year object Year thisYear = Year.of(2018); // Print the string representation System.out.println(thisYear.toString()); } } Output: 2018 Program 2: Java // Program to illustrate the toString() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Create a valid Year object Year thisYear = Year.of(1997); // Print the string representation System.out.println(thisYear.toString()); } } Output: 1997 Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#toString-- 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 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 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 Date toString() method in Java with Examples The toString() method of Java Date class converts this date object into a String in form "dow mon dd hh:mm:ss zzz yyy". This method overrides toString in class object. Syntax: public String toString() Parameters: The function does not accept any parameter. Return Value: It method returns a string re 2 min read Date toString() method in Java with Examples The toString() method of Java Date class converts this date object into a String in form "dow mon dd hh:mm:ss zzz yyy". This method overrides toString in class object. Syntax: public String toString() Parameters: The function does not accept any parameter. Return Value: It method returns a string re 2 min read Like