Class Rounder
java.lang.Object
com.northconcepts.datapipeline.transform.format.Rounder
Rounds numbers to a number of decimal places using a
Rounder.RoundingPolicy.-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRounder(Rounder.RoundingPolicy roundPolicy, int decimalPlaces) Creates a rounder; a negativedecimalPlacesrounds to the left of the decimal point (for example, -2 rounds to hundreds). -
Method Summary
Modifier and TypeMethodDescriptiondoubleapply(double value) Rounds the value in double arithmetic; the UNNECESSARY policy returns it unchanged.apply(BigDecimal value) Returns the value with its scale set to the decimal places using this policy, ornullfor null; HALF_ODD is not supported.apply(BigInteger value) Rounds the value as aBigDecimal, so only negative decimal places change it; returnsnullfor null.intReturns the number of decimal places to round to; negative values round to the left of the decimal point.setDecimalPlaces(int decimalPlaces) Sets the number of decimal places to round to; negative values round to the left of the decimal point.setRoundPolicy(Rounder.RoundingPolicy roundPolicy) toString()
-
Constructor Details
-
Rounder
Creates a rounder; a negativedecimalPlacesrounds to the left of the decimal point (for example, -2 rounds to hundreds).
-
-
Method Details
-
getDecimalPlaces
public int getDecimalPlaces()Returns the number of decimal places to round to; negative values round to the left of the decimal point. -
setDecimalPlaces
Sets the number of decimal places to round to; negative values round to the left of the decimal point. -
getRoundPolicy
-
setRoundPolicy
-
apply
public double apply(double value) Rounds the value in double arithmetic; the UNNECESSARY policy returns it unchanged. -
apply
Returns the value with its scale set to the decimal places using this policy, ornullfor null; HALF_ODD is not supported. -
apply
Rounds the value as aBigDecimal, so only negative decimal places change it; returnsnullfor null. -
toString
-