This method adjusts the provided temporal object to this local date object.
It returns the same type as of provided temporal type.
This method replaces the overlapping parts between this LocalDate and the provided temporal object. Returned temporal object has the same fields as of this fields.
package com.logicbig.example.localdate;
import java.time.*;
import java.time.temporal.Temporal;
public class AdjustIntoExample {
public static void main (String[] args) {
LocalDate d = LocalDate.of(2010, Month.JANUARY, 10);
Temporal t = d.adjustInto(ZonedDateTime.of(LocalDateTime.now(),
ZoneId.of("America/Chicago")));
System.out.println(t);
}
}
Output
2010-01-10T16:37:27.200-06:00[America/Chicago]
package com.logicbig.example.localdate;
import java.time.LocalDate;
import java.time.Month;
import java.time.YearMonth;
import java.time.temporal.Temporal;
public class AdjustIntoExample3 {
public static void main (String[] args) {
LocalDate d = LocalDate.of(2010, Month.JANUARY, 10);
Temporal t = d.adjustInto(YearMonth.of(2015, Month.AUGUST));
System.out.println(t);
}
}
Output
Caused by: java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: EpochDay
at java.time.YearMonth.with(YearMonth.java:693)
at java.time.YearMonth.with(YearMonth.java:131)
at java.time.chrono.ChronoLocalDate.adjustInto(ChronoLocalDate.java:548)
at java.time.LocalDate.adjustInto(LocalDate.java:1550)
at com.logicbig.example.localdate.AdjustIntoExample3.main(AdjustIntoExample3.java:15)
... 6 more