List of usage examples for java.math BigDecimal toString
@Override
public String toString()
From source file:json_cmp.Comparer.java
public static void FloatingtoInt(ObjectNode obj, String str) { //System.out.println(" " + str + " " + obj.path(str).asDouble()); BigDecimal temp = new BigDecimal(obj.path(str).asDouble()).setScale(0, BigDecimal.ROUND_HALF_UP); //int temp = (int) Math.ceil(obj.path(str).asDouble()); ((ObjectNode) obj).put(str, temp.toString()); int output = (int) obj.path(str).asDouble(); ((ObjectNode) obj).put(str, output); // System.out.println(mediaObj.path(str1).path(str2)); }
From source file:org.mifos.config.AccountingRules.java
public static void setMaxInterest(BigDecimal maxInterest) { MifosConfigurationManager.getInstance().setProperty(AccountingRulesConstants.MAX_INTEREST, maxInterest.toString()); }
From source file:org.mifos.config.AccountingRules.java
public static void setMinInterest(BigDecimal minInterest) { MifosConfigurationManager.getInstance().setProperty(AccountingRulesConstants.MIN_INTEREST, minInterest.toString()); }
From source file:org.apache.carbondata.core.util.DataTypeUtil.java
private static String parseStringToBigDecimal(String value, CarbonDimension dimension) { BigDecimal bigDecimal = new BigDecimal(value).setScale(dimension.getColumnSchema().getScale(), RoundingMode.HALF_UP); BigDecimal normalizedValue = normalizeDecimalValue(bigDecimal, dimension.getColumnSchema().getPrecision()); if (null != normalizedValue) { return normalizedValue.toString(); }//from w w w . j a va2 s . com return null; }
From source file:org.mifos.config.AccountingRules.java
public static void setFinalRoundOffMultiple(BigDecimal finalRoundOffMultiple) { MifosConfigurationManager.getInstance().setProperty(AccountingRulesConstants.FINAL_ROUND_OFF_MULTIPLE, finalRoundOffMultiple.toString()); }
From source file:org.mifos.config.AccountingRules.java
public static void setInitialRoundOffMultiple(BigDecimal initialRoundOffMultiple) { MifosConfigurationManager.getInstance().setProperty(AccountingRulesConstants.INITIAL_ROUND_OFF_MULTIPLE, initialRoundOffMultiple.toString()); }
From source file:com.wso2telco.core.dbutils.DbUtils.java
/** * Format.//from w w w. j a v a 2s. co m * * @param doubData * the doub data * @param precision * the precision * @param scale * the scale * @return the string * @throws Exception * the exception */ public static String format(double doubData, int precision, int scale) throws Exception { BigDecimal decData = new BigDecimal(doubData); decData = decData.setScale(scale, BigDecimal.ROUND_HALF_EVEN); String strData = decData.toString(); // prepare the final string int finalLen = precision + 1; String finalStr; if (finalLen <= strData.length()) { finalStr = strData.substring(0, finalLen); } else { finalStr = ""; for (int i = 0; i < finalLen - strData.length(); i++) { finalStr = finalStr + " "; } finalStr = finalStr + strData; } return (finalStr); }
From source file:com.wso2telco.core.dbutils.DbUtils.java
/** * Format./*from w ww . j a v a2s . c om*/ * * @param decData * the dec data * @param precision * the precision * @param scale * the scale * @return the string * @throws Exception * the exception */ public static String format(BigDecimal decData, int precision, int scale) throws Exception { decData = decData.setScale(scale, BigDecimal.ROUND_HALF_EVEN); String strData = decData.toString(); // prepare the final string int finalLen = precision + 1; String finalStr; if (finalLen <= strData.length()) { finalStr = strData.substring(0, finalLen); } else { finalStr = ""; for (int i = 0; i < finalLen - strData.length(); i++) { finalStr = finalStr + " "; } finalStr = finalStr + strData; } return (finalStr); }
From source file:org.olat.core.util.Formatter.java
License:asdf
/** * Format a float as string with given number of figures after comma * //from w w w . j ava 2 s . c om * @param value * @param decimalPlace * @return formatted string */ public static String roundToString(float value, int decimalPlace) { BigDecimal bd = new BigDecimal(value); bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP); return bd.toString(); }
From source file:de.jfachwert.math.PackedDecimal.java
/** * Liefert den uebergebenen String als {@link PackedDecimal} zurueck. * Diese Methode ist dem Konstruktor vorzuziehen, da fuer gaengige Zahlen * wie "0" oder "1" immer das gleiche Objekt zurueckgegeben wird. * * @param zahl beliebige Zahl/*from ww w .j av a 2 s . co m*/ * @return Zahl als {@link PackedDecimal} */ public static PackedDecimal valueOf(BigDecimal zahl) { return valueOf(zahl.toString()); }