Period normalized() method in Java with Examples Last Updated : 27 Nov, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 year and month of the period. Exceptions: It throws an ArithmeticException. This exception is caught if numeric overflow occurs. Below program illustrates the above method: Program 1: Java // Java code to show the function to normalize // months and years of the period import java.time.Period; import java.time.temporal.ChronoUnit; public class PeriodClass { // Function to normalize given periods static void toNormalize(Period p1) { System.out.println(p1.normalized()); } // Driver Code public static void main(String[] args) { // Defining period int year = 4; int months = 15; int days = 10; Period p1 = Period.of(year, months, days); toNormalize(p1); } } Output: P5Y3M10D Program 2: This will not normalize the number of days. Java // Java code to show the function to normalize // months and years of the period import java.time.Period; import java.time.temporal.ChronoUnit; public class PeriodClass { // Function to normalize given periods static void toNormalize(Period p1) { System.out.println(p1.normalized()); } // Driver Code public static void main(String[] args) { // Defining period int year = 10; int months = 25; int days = 366; Period p1 = Period.of(year, months, days); toNormalize(p1); } } Output: P12Y1M366D Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Period.html#normalized-- 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 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 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 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 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. Syntax: public Period multipliedBy(int toM 2 min read Period ofDays() method in Java with Examples The ofDays() method of Period Class is used to obtain a period from given number of Days as parameter. This parameter is accepted in the form of integer. This method returns a Period with the given number of days. Syntax: public static Period ofDays(int numberOfDays) Parameters: This method accepts 2 min read Like