Duration.Multiply Method

Definition

Overloads

Multiply(BigDecimal)

Computes a new duration whose value is factor times longer than the value of this duration.

Multiply(Int32)

Computes a new duration whose value is factor times longer than the value of this duration.

Multiply(BigDecimal)

Computes a new duration whose value is factor times longer than the value of this duration.

[Android.Runtime.Register("multiply", "(Ljava/math/BigDecimal;)Ljavax/xml/datatype/Duration;", "GetMultiply_Ljava_math_BigDecimal_Handler")]
public abstract Javax.Xml.Datatype.Duration? Multiply (Java.Math.BigDecimal? factor);
[<Android.Runtime.Register("multiply", "(Ljava/math/BigDecimal;)Ljavax/xml/datatype/Duration;", "GetMultiply_Ljava_math_BigDecimal_Handler")>]
abstract member Multiply : Java.Math.BigDecimal -> Javax.Xml.Datatype.Duration

Parameters

factor
BigDecimal

to multiply by

Returns

returns a non-null valid Duration object

Attributes

Exceptions

if operation produces fraction in the months field.

if the factor parameter is null.

Remarks

Computes a new duration whose value is factor times longer than the value of this duration.

For example,

"P1M" (1 month) * "12" = "P12M" (12 months)
            "PT1M" (1 min) * "0.3" = "PT18S" (18 seconds)
            "P1M" (1 month) * "1.5" = IllegalStateException

Since the Duration class is immutable, this method doesn't change the value of this object. It simply computes a new Duration object and returns it.

The operation will be performed field by field with the precision of BigDecimal. Since all the fields except seconds are restricted to hold integers, any fraction produced by the computation will be carried down toward the next lower unit. For example, if you multiply "P1D" (1 day) with "0.5", then it will be 0.5 day, which will be carried down to "PT12H" (12 hours). When fractions of month cannot be meaningfully carried down to days, or year to months, this will cause an IllegalStateException to be thrown. For example if you multiple one month by 0.5.

To avoid IllegalStateException, use the #normalizeWith(Calendar) method to remove the years and months fields.

Java documentation for javax.xml.datatype.Duration.multiply(java.math.BigDecimal).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Multiply(Int32)

Computes a new duration whose value is factor times longer than the value of this duration.

[Android.Runtime.Register("multiply", "(I)Ljavax/xml/datatype/Duration;", "GetMultiply_IHandler")]
public virtual Javax.Xml.Datatype.Duration? Multiply (int factor);
[<Android.Runtime.Register("multiply", "(I)Ljavax/xml/datatype/Duration;", "GetMultiply_IHandler")>]
abstract member Multiply : int -> Javax.Xml.Datatype.Duration
override this.Multiply : int -> Javax.Xml.Datatype.Duration

Parameters

factor
Int32

Factor times longer of new Duration to create.

Returns

New Duration that is factortimes longer than this Duration.

Attributes

Remarks

Computes a new duration whose value is factor times longer than the value of this duration.

This method is provided for the convenience. It is functionally equivalent to the following code:

multiply(new BigDecimal(String.valueOf(factor)))

Java documentation for javax.xml.datatype.Duration.multiply(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to