This method adjusts and returns the copy of the specified temporal object having this year-month fields.

package com.logicbig.example.yearmonth;
import java.time.*;
import java.time.temporal.Temporal;
public class AdjustIntoExample {
public static void main(String... args) {
YearMonth y = YearMonth.of(2010, 11);
System.out.println(y);
adjust(y, LocalDate.now());
adjust(y, LocalDateTime.now());
adjust(y, OffsetDateTime.now());
adjust(y, ZonedDateTime.now());
adjust(y, YearMonth.now());
}
private static void adjust(YearMonth y, Temporal t) {
Temporal t2 = y.adjustInto(t);
System.out.printf("%15s > %s > %s%n",
t.getClass().getSimpleName(),
t, t2);
}
}
Output
2010-11
LocalDate > 2025-10-28 > 2010-11-28
LocalDateTime > 2025-10-28T20:46:06.948 > 2010-11-28T20:46:06.948
OffsetDateTime > 2025-10-28T20:46:06.948+08:00 > 2010-11-28T20:46:06.948+08:00
ZonedDateTime > 2025-10-28T20:46:06.950+08:00[America/Chicago] > 2010-11-28T20:46:06.950+08:00[America/Chicago]
YearMonth > 2025-10 > 2010-11