LocalDateTime withDayOfYear(int dayOfYear)
returns
a copy of this LocalDateTime with the day-of-year altered.
withDayOfYear
has the following syntax.
public LocalDateTime withDayOfYear(int dayOfYear)
The following example shows how to use withDayOfYear
.
import java.time.LocalDateTime; /*from ww w .j a va 2s .c o m*/ public class Main { public static void main(String[] args) { LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01); LocalDateTime t = a.withDayOfYear(2012); System.out.println(t); } }