Class DoubleFormatter

java.lang.Object
com.reve.utils.DoubleFormatter

public class DoubleFormatter extends Object
This class is aimed to round e double value to a given decimal places. For memory leakage issue, we cannot use Double.parseDouble(String) method. Instead, we will divide and round.
  • Constructor Details

    • DoubleFormatter

      public DoubleFormatter(int decimalPlace, DoubleFormatter.RoundingMethod roundingMethod)
      Constructor
      Parameters:
      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.
    • DoubleFormatter

      public DoubleFormatter(int decimalPlace)
      Constructor
      Parameters:
      decimalPlace - Number of digits after dot, the value should be rounded to.
  • Method Details

    • formatDouble

      public Double formatDouble(Double value)
      Round the double value to the decimal value given in the constructor.
      Parameters:
      value - The value to be rounded.
      Returns:
      Rounded value.