Duration dividedBy(long) method in Java with Examples Last Updated : 26 Nov, 2018 Comments Improve Suggest changes Like Article Like Report The dividedBy(long) method of Duration Class in java.time package is used to get an immutable copy of this duration divided by the value passed as the parameter. Syntax: public Duration dividedBy(long divisor) Parameters: This method accepts a parameter divisor which is the value to be divided. It can be positive or negative value. Return Value: This method returns a Duration which is an immutable copy of the existing duration with the parameter value divided to it. Exception: This method throws ArithmeticException if numeric overflow occurs. Below examples illustrate the Duration.dividedBy() method: Example 1: Java // Java code to illustrate dividedBy() method import java.time.Duration; public class GFG { public static void main(String[] args) { // Duration 1 using parse() method Duration duration1 = Duration.parse("P2DT3H4M"); // divisor value long divisor = 2; // Get the duration divided // using dividedBy() method System.out.println(duration1 .dividedBy(divisor)); } } Output: PT25H32M Example 2: Java // Java code to illustrate dividedBy() method import java.time.Duration; public class GFG { public static void main(String[] args) { // Duration 1 using parse() method Duration duration1 = Duration.parse("P2DT3H4M"); // divisor value long divisor = 10; // Get the duration divided // using dividedBy() method System.out.println(duration1 .dividedBy(divisor)); } } Output: PT5H6M24S Reference: Oracle Doc Comment More infoAdvertise with us Next Article Duration plusDays(long) method in Java with Examples C code_r Follow Improve Article Tags : Java Java-Functions Java-time package Java-Duration Practice Tags : Java Similar Reads Duration dividedBy(Duration) method in Java with Examples The dividedBy(Duration) method of Duration Class in java.time package is used to get an immutable copy of this duration divided by the duration passed as the parameter. Syntax: public Duration dividedBy(Duration divisor) Parameters: This method accepts a parameter divisor which is the duration to be 2 min read Duration abs() method in Java with Examples The abs() method of Duration Class in java.time package is used to get an immutable copy of this duration with the absolute duration. Syntax: public Duration abs() Parameters: This method do not accepts any parameter. Return Value: This method returns a Duration which is an immutable copy of the exi 1 min read Duration ofDays(long) method in Java with Examples The ofDays(long) method of Duration Class in java.time package is used to get a duration in a 24 hour format. In this method, the seconds are calculated as total seconds in 24 hour day format, i.e. 86400 seconds per day. Syntax: public static Duration ofDays(long days) Parameters: This method accept 1 min read Duration ofMillis(long) method in Java with Examples The ofMillis(long) method of Duration Class in java.time package is used to get a duration in a 1 milliSecond format. Syntax: public static Duration ofMillis(long milliSeconds) Parameters: This method accepts a parameter milliSeconds which is the number of milliSeconds. It can be positive or negativ 1 min read Duration plusDays(long) method in Java with Examples The plusDays(long) method of Duration Class in java.time package is used to get an immutable copy of this duration with the specified number of days added, passed as the parameter. Syntax: public Duration plusDays(long numberOfDays) Parameters: This method accepts a parameter numberOfDays which is t 1 min read Duration ofNanos(long) method in Java with Examples The ofNanos(long) method of Duration Class in java.time package is used to get a duration in a 1 nanoSecond format. Syntax: public static Duration ofNanos(long nanoSeconds) Parameters: This method accepts a parameter nanoSeconds which is the number of nanoSeconds. It can be positive or negative. Ret 1 min read Like