LocalDate ofYearDay() method in Java with Examples Last Updated : 21 May, 2020 Comments Improve Suggest changes Like Article Like Report The ofYearDay(int year, int dayOfYear) method of LocalDate class in Java is used to obtain an instance of LocalDate from an input year and day-of-year. Here no value of the month is passed. The passed year forms the year of the instance and the day and month are calculated on the basis of dayOfYear. Here 1st January forms the starting day. So, if dayOfYear is passed as 32, it means that the first 31 days form the month of January and the 32nd day is 1st of February. Syntax: public static LocalDate ofYearDay(int year, int dayOfYear) Parameters: This method accepts two parameters: year - It is of Integer type and represents the year. It varies from MIN_YEAR to MAX_YEAR. dayOfYear - It is of Integer type and represents the day of the year. It varies from 1 to 366. Return Value: This method returns the localdate. Exceptions: This method throws DateTimeException if the value of any field is out of range or the day-of-year is invalid. Below programs illustrate the ofYearDay(int year, int dayOfYear) method in Java: Program 1: Java // Java program to demonstrate // LocalDate.ofYearDay(int year, // int dayOfYear) method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // create LocalDate object LocalDate localdate = LocalDate.ofYearDay( 2020, 134); // print full date System.out.println("Date: " + localdate); } } Output: Date: 2020-05-13 Program 2: Java // Java program to demonstrate // LocalDate.ofYearDay(int year, int dayOfYear) method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // create LocalDate object LocalDate localdate = LocalDate.ofYearDay( 2020, 134); // print month System.out.println( "Month: " + localdate.getMonth()); } } Output: Month: MAY References: https://docs.oracle.com/javase/10/docs/api/java/time/LocalDate.html#ofYearDay(int, int) Comment More infoAdvertise with us Next Article LocalDate plusYears() method in Java with Examples P pp_pankaj Follow Improve Article Tags : Java Java-Functions Java-LocalDate Practice Tags : Java Similar Reads LocalDate plusYears() method in Java with Examples The plusYears() method of LocalDate class in Java is used to add the number of specified years in this LocalDate and return a copy of LocalDate. This method adds the years field in the following steps: Add the years to the year field. Check if the date after adding years is valid or not. If date is 2 min read LocalDate plusYears() method in Java with Examples The plusYears() method of LocalDate class in Java is used to add the number of specified years in this LocalDate and return a copy of LocalDate. This method adds the years field in the following steps: Add the years to the year field. Check if the date after adding years is valid or not. If date is 2 min read LocalDate plusDays() Method in Java with Examples The plusDays() method of a LocalDate class in Java is used to add the number of specified day in this LocalDate and return a copy of LocalDate. For example, 2018-12-31 plus one day would result in 2019-01-01. This instance is immutable and unaffected by this method call. Syntax: public LocalDate plu 2 min read LocalDate plusDays() Method in Java with Examples The plusDays() method of a LocalDate class in Java is used to add the number of specified day in this LocalDate and return a copy of LocalDate. For example, 2018-12-31 plus one day would result in 2019-01-01. This instance is immutable and unaffected by this method call. Syntax: public LocalDate plu 2 min read LocalDateTime plusDays() method in Java with Examples The plusDays() method of LocalDateTime class is used to return a copy of this date-time with the specified days added. Syntax: public LocalDateTime plusDays(long days) Parameter: It accepts a single parameter days which specifies the days to add which may be negative. Return Value: This method retur 1 min read LocalDateTime plusDays() method in Java with Examples The plusDays() method of LocalDateTime class is used to return a copy of this date-time with the specified days added. Syntax: public LocalDateTime plusDays(long days) Parameter: It accepts a single parameter days which specifies the days to add which may be negative. Return Value: This method retur 1 min read Like