The addTo(Temporal) method of ChronoPeriod Interface in java.time.chrono package is used add this ChronoPeriod to the specified temporal object, passed as the parameter.
Temporal addTo(Temporal temporalObject)
Parameters: This method accepts a parameter temporalObject which is the amount to be adjusted in this ChronoPeriod. It should not be null.
Return Value: This method returns an object of the same type with the temporalObject adjusted to it.
Exception: This method throws:
- DateTimeException: if unable to add.
- ArithmeticException: if numeric overflow occurs.
Below examples illustrate the ChronoPeriod.addTo() method:
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.