LocalDate getYear() method in Java with Examples Last Updated : 29 Nov, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The getYear() method of LocalDate class in Java gets the year field. Syntax: public int getYear() Parameter: This method does not accepts any parameter. Return Value: The function returns the year, from MIN_YEAR to MAX_YEAR Below programs illustrate the getYear() method of LocalDate in Java: Program 1: Java // Program to illustrate the getYear() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Parses the date LocalDate dt = LocalDate.parse("2018-11-27"); // Prints the day number System.out.println(dt.getYear()); } } Output: 2018 Program 2: Java // Program to illustrate the getYear() method import java.util.*; import java.time.*; public class GfG { public static void main(String[] args) { // Parses the date LocalDate dt = LocalDate.parse("2015-11-27"); // Prints the day number System.out.println(dt.getYear()); } } Output: 2015 Reference: https://docs.oracle.com/javase/10/docs/api/java/time/LocalDate.html#getYear() Comment More infoAdvertise with us Next Article LocalDate getYear() method in Java with Examples G gopaldave Follow Improve Article Tags : Java Java-Functions Java-time package Java-LocalDate Practice Tags : Java Similar Reads LocalDate getEra() method in Java with Examples The getEra() method of LocalDate class in Java gets the era applicable at this date. Syntax: public Era getEra() Parameter: This method does not accepts any parameter. Return Value: The function returns the IsoChronology era constant applicable at this date and not null. Below programs illustrate th 1 min read LocalDateTime getYear() method in Java with Examples The getYear() method of an LocalDateTime class is used to return the year field.This method returns the primitive int value for the year from MIN_YEAR to MAX_YEAR. Syntax: public int getYear() Parameter: This method does not accept any parameter. Returns: This method returns an integer value which i 1 min read LocalDate getDayOfYear() method in Java with Examples The getDayOfYear() method of LocalDate class in Java gets the day-of-year field. Syntax: public int getDayOfYear() Parameter: This method does not accepts any parameter. Return Value: The function returns the day of the year which is in range [1, 365/366] depending on leap year or not. Below program 1 min read LocalDate get() method in Java with Examples The get() method of LocalDate class in Java method gets the value of the specified field from this Date as an int. Syntax: public int get(TemporalField field) Parameter: This method accepts a parameter field which is the field to get and not necessary null. Return Value: It returns the value for the 2 min read LocalDateTime getDayOfYear() method in Java with Examples The getDayOfYear() method of an LocalDateTime class is used to return the day-of-year field. This method returns an integer value ranging from 1 to 365 (366 for a leap year), i.e. the Days of a years. Syntax: public int getDayOfYear() Parameter: This method does not accept any parameter. Returns: Th 1 min read Like