This method adjusts the specified temporal object to have the same date, time and offset fields as this object
This method will throw UnsupportedTemporalTypeException if the provided temporal object does not support the OffsetDateTime fields.
package com.logicbig.example.offsetdatetime;
import java.time.*;
import java.time.temporal.Temporal;
public class AdjustIntoExample {
public static void main (String... args) {
OffsetDateTime d = OffsetDateTime.of(LocalDate.ofYearDay(2016, 300),
LocalTime.NOON,
ZoneOffset.ofHours(-6));
System.out.println(d);
ZonedDateTime z = ZonedDateTime.now();
System.out.println(z);
Temporal t = d.adjustInto(z);
System.out.println(t);
//alternatively
ZonedDateTime z2 = z.with(d);
System.out.println(z2);
}
}
Output
2016-10-26T12:00-06:00
2017-05-01T15:54:46.281-05:00[America/Chicago]
2016-10-26T12:00-05:00[America/Chicago]
2016-10-26T12:00-05:00[America/Chicago]