@Override public Value convertScale(boolean onlyToSmallerScale, int targetScale) { if (value.scale() == targetScale) { return this; } if (onlyToSmallerScale || targetScale >= DEFAULT_SCALE) { if (value.scale() < targetScale) { return this; } } BigDecimal bd = ValueDecimal.setScale(value, targetScale); return ValueDecimal.get(bd); }
@Override public Value convertScale(boolean onlyToSmallerScale, int targetScale) { if (targetScale >= DEFAULT_SCALE) { return this; } if (targetScale < 0) { throw DbException.getInvalidValueException("scale", targetScale); } long n = nanos; BigDecimal bd = BigDecimal.valueOf(n); bd = bd.movePointLeft(9); bd = ValueDecimal.setScale(bd, targetScale); bd = bd.movePointRight(9); long n2 = bd.longValue(); if (n2 == n) { return this; } return fromDateValueAndNanos(dateValue, n2); }
/** * Returns the value of the specified column as a BigDecimal. * * @deprecated use {@link #getBigDecimal(int)} * * @param columnIndex (1,2,...) * @param scale the scale of the returned value * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Deprecated @Override public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { try { if (isDebugEnabled()) { debugCode("getBigDecimal(" + columnIndex + ", " + scale + ");"); } if (scale < 0) { throw DbException.getInvalidValueException("scale", scale); } BigDecimal bd = get(columnIndex).getBigDecimal(); return bd == null ? null : ValueDecimal.setScale(bd, scale); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as a BigDecimal. * * @deprecated use {@link #getBigDecimal(String)} * * @param columnLabel the column label * @param scale the scale of the returned value * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Deprecated @Override public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { try { if (isDebugEnabled()) { debugCode("getBigDecimal(" + StringUtils.quoteJavaString(columnLabel) + ", " + scale + ");"); } if (scale < 0) { throw DbException.getInvalidValueException("scale", scale); } BigDecimal bd = get(columnLabel).getBigDecimal(); return bd == null ? null : ValueDecimal.setScale(bd, scale); } catch (Exception e) { throw logAndConvert(e); } }