The adjustInto(Temporal) method of ZoneOffset Class in java.time package is used to obtain an adjusted Temporal instance with this instance of ZoneOffset adjusted into it. This method takes the Temporal instance as parameter and returns an Temporal instance, which is the adjusted instance.
public Temporal adjustInto(Temporal temporalInstance)
Parameters: This method accepts accepts a parameter temporalInstance which is the Temporal instance to be adjusted.
Return Value: This method returns a Temporal instance which is the adjusted value of this Temporal instance.
Exceptions: This method throws following exceptions:
- DateTimeException: if unable to make the adjustment
- ArithmeticException: if numeric overflow occurs.
Below examples illustrate the ZoneOffset.adjustInto() method:
Original Temporal instance: 2018-12-11T09:44:14.373Z[Etc/UTC] Adjusted Temporal instance: 2018-12-11T09:44:14.373Z[Etc/UTC]
Original Temporal instance: 2018-12-11T09:44:16.893Z Adjusted Temporal instance: 2018-12-11T09:44:16.893+05:00
Reference: Oracle Doc
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.