BigDecimal decVal = toBigDecimal(value);
try { BigDecimal decVal = toBigDecimal(value);
  private void writeCurrencyValue(ByteBuffer buffer, Object value)  {    BigDecimal decVal = toBigDecimal(value);    // adjust scale (this will throw if number has too many decimal places)    decVal = decVal.setScale(4);        // now, remove scale and convert to long (this will throw if the value is    // too big)    buffer.putLong(decVal.movePointRight(4).longValueExact());  }