Period multipliedBy() method in Java with Examples Last Updated : 27 Nov, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. Syntax: 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: Program 1: Java // Java code to show the function multipliedBy() // to multiply the given number to given period import java.time.Period; import java.time.temporal.ChronoUnit; public class PeriodClass { // Function to multiply a constant to given periods static void multiply(Period p1, int toMultiply) { System.out.println(p1.multipliedBy(toMultiply)); } // Driver Code public static void main(String[] args) { // Defining first period int year = 4; int months = 11; int days = 10; Period p1 = Period.of(year, months, days); int toMultiply = 2; multiply(p1, toMultiply); } } Program 2: Java // Java code to show the function multipliedBy() // to multiply the given number to given period import java.time.Period; import java.time.temporal.ChronoUnit; public class PeriodClass { // Function to multiply a constant to given periods static void multiply(Period p1, int toMultiply) { System.out.println(p1.multipliedBy(toMultiply)); } // Driver Code public static void main(String[] args) { // Defining first period int year = -4; int months = -11; int days = -10; Period p1 = Period.of(year, months, days); int toMultiply = 2; multiply(p1, toMultiply); } } Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Period.html#multipliedBy-int- Comment More infoAdvertise with us Next Article Period negated() method in Java with Examples B barykrg Follow Improve Article Tags : Misc Java Java-Functions Java-time package Java-Period +1 More Practice Tags : JavaMisc Similar Reads Period normalized() method in Java with Examples The normalized() method of Period class in Java is used to return a new instance of Period after normalizing years and months. Syntax: public Period normalized() Parameters: This function does not accepts any parameter. Return Value: This function returns a new instance of Period after normalizing y 2 min read Period minusDays() method in Java with Examples The minusDays() method of Period class in Java is used to subtract the days from this Period. This functions operates only on DAYS and does not affect YEAR and MONTH. Syntax: public Period minusDays(long daysToSubtract) Parameters: This method accepts a single parameter daysToSubtract which is the n 2 min read Period negated() method in Java with Examples The negated() method of Period class in Java is used to return a new instance of Period after negating all the elements of the period YEAR, MONTH, DAY. Syntax: public Period negated() Parameters: This method does not accepts any parameter. Return Value: This method returns a new instance of Period a 2 min read Period minus() method in Java with Examples The minus() method of Period class in Java is used to subtract the given amount of period from the specified period. This functions operates separately on YEAR, MONTH and DAY. Note: Normalization is not performed. 12 months and 1 year are different. Syntax: public Period minus(TemporalAmount amountT 2 min read Period parse() method in Java with Examples The parse() method of Period Class is used to obtain a period from given string in the form of PnYnMnD where nY means n years, nM means n months and nD means n days. Syntax: public static Period parse(CharSequence text) Parameters: This method accepts a single parameter text which is the String to b 2 min read Period of() method in Java with Examples The of() method of Period Class is used to obtain a period from given number of Years, Months, and Days as parameters. These parameters are accepted in the form of integers. This method returns a Period with the given number of years, months, and days. Syntax: public static Period of( int numberOfYe 2 min read Like