Period multipliedBy() method in Java with Examples
The multipliedBy() method of Period class in Java is used to return a new instance of Period after multiplying ‘X’ (scalar quantity) each element of the period YEAR, MONTH, DAY from given period. This functions operates only on all three YEAR, MONTHS, DAYS.
public Period multipliedBy(int toMultiply)
Parameters: This method accepts a single parameter toMultiply which is the scalar number to be multiplied to the period.
Return Value: This method returns a new instance of Period after multiplying each element of the period with the given toMultiply input.
Exceptions: It throws an ArithmeticException.This exception is caught if numeric overflow occurs.
Below is the implementation of the above 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.