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);
  }
}




















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset