adjustInto() method of the Year class used to adjusts the passed temporal object to have this year on which this method is applied.This instance is immutable and unaffected by this method call.
public Temporal adjustInto(Temporal temporal)
Parameters: This method accepts temporal as parameter which is the target temporal object to be adjusted. It should not be null.
Return value: This method returns the adjusted object.
Exception: This method throws following Exceptions:
- DateTimeException – if unable to make the adjustment.
- ArithmeticException – if numeric overflow occurs.
Below programs illustrate the adjustInto() method:
LocalDate :2007-12-03 LocalDate after applying adjustInto method: 2019-12-03
LocalDate :2017-01-13 LocalDate after applying adjustInto method: 2032-01-13
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.