OffsetDateTime with(TemporalAdjuster adjuster) example

Description

OffsetDateTime with(TemporalAdjuster adjuster) returns an adjusted copy of this date-time.

Syntax

with has the following syntax.


public OffsetDateTime with(TemporalAdjuster adjuster)

Example

The following example shows how to use with.


import java.time.LocalDate;
import java.time.OffsetDateTime;
/*from  w  w w .  j a  v  a2  s  .co  m*/
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    OffsetDateTime d = o.with(LocalDate.now());
    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