The plusMillis() method of Instant class adds specified duration in milliseconds to this instant and returns the result as an instant object. This returned Instant is immutable.
public Instant plusMillis(long millisToAdd)
Parameters: This method accepts one parameter millisToAdd which is milliseconds to add.
Returns: This method returns Instant with the milliseconds added to it.
Exception: This method throws following exceptions:
- DateTimeException: if the result exceeds the maximum or minimum instant.
- ArithmeticException: if numeric overflow occurs.
Below programs illustrate the plusMillis() 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.