Java Date Time Java Java API
java.time.LocalDateTime
public LocalDateTime withDayOfYear(int dayOfYear)
Returns a copy of this LocalDateTime with the day-of-year replaced with the specified
dayOfYear value. This method will throw exception for a value like 367, because 367 is not a valid value of any year.
package com.logicbig.example.localdatetime;import java.time.LocalDateTime;public class WithDayOfYearExample { public static void main (String... args) { LocalDateTime dt = LocalDateTime.of(2000, 5, 3, 20, 10); LocalDateTime dt2 = dt.withDayOfYear(200); System.out.println(dt2); }}
2000-07-18T20:10