Adjusts the specified temporal object to have this instant fields. This returns a temporal object of the same type as of the input temporal type. The input temporal object must support all field used by this Instant object
package com.logicbig.example.instant;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import java.time.temporal.Temporal;
public class AdjustIntoExample {
public static void main(String... args) {
Instant i = Instant.parse("2017-04-09T10:15:30.00Z");
System.out.println(i);
adjustInto(i, OffsetDateTime.now());
adjustInto(i, ZonedDateTime.now());
adjustInto(i, Instant.now());
}
private static void adjustInto(Instant i, Temporal t) {
Temporal t2 = i.adjustInto(t);
System.out.printf("%15s > %s > %s%n", t.getClass().getSimpleName(), t, t2);
}
}
Output
2017-04-09T10:15:30Z
OffsetDateTime > 2017-05-01T15:50:28.538-05:00 > 2017-04-09T05:15:30-05:00
ZonedDateTime > 2017-05-01T15:50:28.540-05:00[America/Chicago] > 2017-04-09T05:15:30-05:00[America/Chicago]
Instant > 2017-05-01T20:50:28.540Z > 2017-04-09T10:15:30Z