Returns the new instance of a temporal object to having this month-day. The returned temporal object is of the same type as of the input type.
package com.logicbig.example.monthday;
import java.time.*;
import java.time.temporal.Temporal;
public class AdjustIntoExample {
public static void main(String... args) {
MonthDay m = MonthDay.of(10, 20);
System.out.println(m);
adjust(m, LocalDate.now());
adjust(m, LocalDateTime.now());
adjust(m, ZonedDateTime.now());
adjust(m, OffsetDateTime.now());
}
private static void adjust(MonthDay m, Temporal t) {
Temporal t2 = m.adjustInto(t);
System.out.printf("%15s > %s > %s%n",
t.getClass().getSimpleName(),
t, t2);
}
}
Output
--10-20
LocalDate > 2017-05-01 > 2017-10-20
LocalDateTime > 2017-05-01T15:54:44.163 > 2017-10-20T15:54:44.163
ZonedDateTime > 2017-05-01T15:54:44.164-05:00[America/Chicago] > 2017-10-20T15:54:44.164-05:00[America/Chicago]
OffsetDateTime > 2017-05-01T15:54:44.164-05:00 > 2017-10-20T15:54:44.164-05:00