Class BMoney

    • Constructor Detail

      • BMoney

        public BMoney​(double val,
                      int scale)
        Creates a BMoney value.
        Parameters:
        val - double-representation of the number
        scale - the digits after comma the value should be rounded to
      • BMoney

        public BMoney​(String val,
                      int scale)
        Creates a BMoney value.
        Parameters:
        val - the string
        scale - the digits after comma the value should be rounded to
      • BMoney

        public BMoney​(int scale)
        Creates a zero BMoney value.
        Parameters:
        scale - the digits after comma
      • BMoney

        public BMoney​(BigInteger intVal,
                      int scale)
        Creates a BMoney value from a BigInteger.
        The scale sets the comma within the given integer.
        Parameters:
        intVal - the big integer
        scale - the digits after comma
      • BMoney

        public BMoney​(BMoney val,
                      int scale)
        Creates a BMoney from a BMoney (useful to rescale)
        Parameters:
        val - the BMoney value
        scale - the digits after comma the value should be rounded to
      • BMoney

        public BMoney​(BigDecimal val)
        Creates a BMoney from a BigDecimal (userful for SQL)
        Parameters:
        val - the decimal value
      • BMoney

        public BMoney()
        Creates a zero BMoney with a scale according to the currency of the current locale.
    • Method Detail

      • clone

        public BMoney clone()
        Clones a BMoney value.
        Overrides:
        clone in class Object
      • isNegative

        public boolean isNegative()
        Checks if this money value is negative.
        Returns:
        true if number is negative
      • isPositive

        public boolean isPositive()
        Checks if this money value is positive.
        Returns:
        true if number is positive
      • isZero

        public boolean isZero()
        Checks if this money value is zero.
        Returns:
        true if number is zero
      • add

        public BMoney add​(BMoney val)
        Adds a BMoney to this value and returns a new object. This object remains unchanged.
        Parameters:
        val - the money value to add
        Returns:
        the sum of this and given value
      • subtract

        public BMoney subtract​(BMoney val)
        Subtracts a BMoney from this value and returns a new object. This object remains unchanged.
        Parameters:
        val - the money value to subtract
        Returns:
        this minus the given value
      • multiply

        public BMoney multiply​(double val)
        Multiplies this BMoney by a double and returns a new object. This object remains unchanged.
        Parameters:
        val - the double to multiply with
        Returns:
        the product of this and given value
      • divide

        public double divide​(BMoney val)
        Divides a BMoney by this value and returns a new object. This object remains unchanged.
        Parameters:
        val - the money value to multiply
        Returns:
        the quotient of this and given value
      • divide

        public BMoney divide​(double val)
        Divides a BMoney by double and returns a new object. This object remains unchanged.
        Parameters:
        val - the value to divide this BMoney by
        Returns:
        the quotient of this and given value
      • invert

        public BMoney invert()
        Inverts this money value.
        Returns:
        the negated money value
      • absolute

        public BMoney absolute()
        Gets the absolute value.
        Returns:
        the absolute (positive) value
      • smallestPositive

        public BMoney smallestPositive()
        Returns the smalles positive value.
        Ex.: if scale is 2 --> 0.01 will be returned.
        Returns:
        the smalles positive value
      • toWords

        public String toWords()
        Converts a money value to a string of digits as words.
        The digits after the comma are ignored. Nice to print checks.
         Example: 234,77 will become "two three four"
         
        Returns:
        the value as a words
      • alignScale

        protected BMoney alignScale​(BMoney val)
        Check the scale of the given money value. If it does not match the scale of this object, scale it to the current scale of this object.
        Parameters:
        val - the value to be checked
        Returns:
        the re-scaled value or the value itself if no rescaling necessary