Java Date Time - OffsetDateTime with(TemporalAdjuster adjuster) example








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;
/*ww  w .  ja va 2  s.c o 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.