Java Date Time - OffsetDateTime adjustInto(Temporal temporal) example








OffsetDateTime adjustInto(Temporal temporal) adjusts the specified temporal object to have the same offset, date and time as this object.

Syntax

adjustInto has the following syntax.

public Temporal adjustInto(Temporal temporal)

Example

The following example shows how to use adjustInto.

import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.temporal.Temporal;
/*from w w  w.j av a2 s.  c  o  m*/
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    Temporal d =  o.adjustInto(OffsetDateTime.now(ZoneId.systemDefault()));
    System.out.println(d);
  }
}

The code above generates the following result.