LocalDateTime 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 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 is the primitive int value for the year from MIN_YEAR to MAX_YEAR. Below programs illustrate the LocalDateTime.getYear() method: Program 1: Java // Java program to demonstrate // LocalDateTime.getYear() method import java.time.*; public class GFG { public static void main(String[] args) { // create a LocalDateTime Object LocalDateTime local = LocalDateTime.parse("2018-12-03T12:39:10"); // get Year int year = local.getYear(); // print result System.out.println("Year: " + year); } } Output: Year: 2018 Program 2: Java // Java program to demonstrate // LocalDateTime.getYear() method import java.time.*; public class GFG { public static void main(String[] args) { // create a LocalDateTime Object LocalDateTime local = LocalDateTime.parse("2019-01-28T22:29:10"); // get Year int year = local.getYear(); // print result System.out.println("Year: " + year); } } Output: Year: 2019 Reference: https://docs.oracle.com/javase/10/docs/api/java/time/LocalDateTime.html#getYear() Comment More infoAdvertise with us Next Article LocalDateTime getDayOfYear() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-LocalDateTime Java-Functions Java-time package Practice Tags : Java Similar Reads LocalDate getYear() method in Java with Examples 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 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 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 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 LocalTime get() method in Java with Examples The get() method of a LocalTime class helps to get the value for the specified field passed as a parameter from this LocalTime as an integer value. This method queries this time for the value of the field and the returned value will always be within the valid range of values for the field. When the 2 min read Like