Class DMoney

All Implemented Interfaces:
Serializable, Cloneable, Comparable<BigDecimal>

public class DMoney extends BMoney
A DMoney is the same as a BMoney but will be treated differently when stored in the database.
A BMoney is stored as a DOUBLE for the value and an INTEGER for the scale. A DMoney is stored as a DECIMAL for the value and an INTEGER for the scale. The DECIMAL is stored with scale 0!
Author:
harald
See Also:
  • Constructor Details

    • DMoney

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

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

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

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

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

      public DMoney(BigDecimal val)
      Creates a DMoney from a BigDecimal.
      Parameters:
      val - the decimal value
    • DMoney

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

    • bigDecimalValue

      public BigDecimal bigDecimalValue()
      Gets the decimal value.
      Returns:
      the decimal value
    • add

      public DMoney add(BMoney val)
      Description copied from class: BMoney
      Adds a BMoney to this value and returns a new object. This object remains unchanged.
      Overrides:
      add in class BMoney
      Parameters:
      val - the money value to add
      Returns:
      the sum of this and given value
    • subtract

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

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

      public DMoney divide(double val)
      Description copied from class: BMoney
      Divides a BMoney by double and returns a new object. This object remains unchanged.
      Overrides:
      divide in class BMoney
      Parameters:
      val - the value to divide this BMoney by
      Returns:
      the quotient of this and given value
    • invert

      public DMoney invert()
      Description copied from class: BMoney
      Inverts this money value.
      Overrides:
      invert in class BMoney
      Returns:
      the negated money value
    • absolute

      public DMoney absolute()
      Description copied from class: BMoney
      Gets the absolute value.
      Overrides:
      absolute in class BMoney
      Returns:
      the absolute (positive) value
    • smallestPositive

      public DMoney smallestPositive()
      Description copied from class: BMoney
      Returns the smallest positive value.
      Ex.: if scale is 2 --> 0.01 will be returned.
      Overrides:
      smallestPositive in class BMoney
      Returns:
      the smallest positive value