public class DoubleFormatter extends Object
Double.parseDouble(String) method. Instead, we will divide and round.| Modifier and Type | Class | Description |
|---|---|---|
static class |
DoubleFormatter.RoundingMethod |
Rounding methods
|
| Constructor | Description |
|---|---|
DoubleFormatter(int decimalPlace) |
Constructor
|
DoubleFormatter(int decimalPlace,
DoubleFormatter.RoundingMethod roundingMethod) |
Constructor
|
| Modifier and Type | Method | Description |
|---|---|---|
Double |
formatDouble(Double value) |
Round the double value to the decimal value given in the constructor.
|
public DoubleFormatter(int decimalPlace,
DoubleFormatter.RoundingMethod roundingMethod)
decimalPlace - Number of digits after dot, the value should be rounded to.roundingMethod - Rounding method can be
either - DoubleFormatter.RoundingMethod.HALF_UP where immediate next digit of last
considered digit greater equal 5 will be considered to ceiling. and less than 5
will be considered to be floor.
or - DoubleFormatter.RoundingMethod.CEILING where greater than 0 will be considered to ceiling.
or - DoubleFormatter.RoundingMethod.FLOOR where all value will be considered to floor.public DoubleFormatter(int decimalPlace)
decimalPlace - Number of digits after dot, the value should be rounded to.Copyright © 2025. All rights reserved.