@Override public DMoney subtract(BMoney val) { return new DMoney(unscaledValue().subtract(alignScale(val).unscaledValue()), scale()); }
@Override public DMoney multiply(double val) { return new DMoney(doubleValue() * val, scale()); }
@Override public DMoney absolute() { return isNegative() ? invert() : this; }
@Override public DMoney invert() { return new DMoney(unscaledValue().negate(), scale()); }
return new DMoney(value, FormatHelper.determineScale(value));
short s = (short) m.scale(); BigDecimal d = m.movePointRight(s);
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as a * <code>DMoney</code> with full precision.<br> * Notice that DMoney fields use two fields: * one for the value and * one for the scale (= name + "_2") * * @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column * @return the column value (full precision); * if the value is SQL <code>NULL</code>, the value returned is * <code>null</code> in the Java programming language. */ public DMoney getDMoney (String name) { try { BigDecimal decimal = resources.rs.getBigDecimal(name); if (!wasNull()) { // set scale return new DMoney(decimal.movePointLeft(getInt(name + "_2"))); } else { return null; } } catch (SQLException e) { throw new PersistenceException(resources.db, e); } }
@Override public DMoney add(BMoney val) { return new DMoney(unscaledValue().add(alignScale(val).unscaledValue()), scale()); }
@Override public DMoney divide(double val) { return new DMoney(doubleValue() / val, scale()); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as a * <code>DMoney</code> with full precision.<br> * Notice that DMoney fields use two fields: * one for the value and * one for the scale (= name + "P") * * @param pos the parameter index for the amount in the result set * @param ppos the parameter index for the scale in the result set * @return the column value (full precision); * if the value is SQL <code>NULL</code>, the value returned is * <code>null</code> in the Java programming language. */ public DMoney getDMoney (int pos, int ppos) { BigDecimal value = getBigDecimal(pos); return wasNull() ? null : new DMoney (value.movePointLeft(getInt(ppos))); }
money = new DMoney(value);
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as a * <code>DMoney</code> with full precision.<br> * Notice that DMoney fields use two fields: * one for the value and * one for the scale (= name + "P") * * @return the column value (full precision); * if the value is SQL <code>NULL</code>, the value returned is * <code>null</code> in the Java programming language. */ public DMoney getDMoney () { BigDecimal value = getBigDecimal(nextConfiguredIndex()); return wasNull() ? null : new DMoney (value.movePointLeft(getInt(nextConfiguredIndex()))); }
money = new DMoney(value);