OffsetDateTime withDayOfYear(int dayOfYear) example

Description

OffsetDateTime withDayOfYear(int dayOfYear) returns a copy of this OffsetDateTime with the day-of-year altered.

Syntax

withDayOfYear has the following syntax.


public OffsetDateTime withDayOfYear(int dayOfYear)

Example

The following example shows how to use withDayOfYear.


import java.time.OffsetDateTime;
//w  w  w  . jav  a  2  s.co  m
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    OffsetDateTime d = o.withDayOfYear(123);
    System.out.println(d);
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




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