LocalDateTime withDayOfYear(int dayOfYear) example
Description
LocalDateTime withDayOfYear(int dayOfYear)
returns
a copy of this LocalDateTime with the day-of-year altered.
Syntax
withDayOfYear
has the following syntax.
public LocalDateTime withDayOfYear(int dayOfYear)
Example
The following example shows how to use withDayOfYear
.
import java.time.LocalDateTime;
//w ww . jav a 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);
}
}