List of usage examples for java.math BigDecimal multiply
public BigDecimal multiply(BigDecimal multiplicand)
(this × multiplicand)
, and whose scale is (this.scale() + multiplicand.scale()) . From source file:adalid.commons.util.ObjUtils.java
public static BigDecimal xMultipliedByY(Object x, Object y) { BigDecimal bx = NumUtils.numberToBigDecimal(x); BigDecimal by = bx == null ? null : NumUtils.numberToBigDecimal(y); return bx == null || by == null ? null : bx.multiply(by); }
From source file:com.core.util.wx.PayUtils.java
/** * @param outTradeNo ??//from ww w . j av a2s . co m * @param openId id * @param cash * @param appId APPID * @param mchId ID * @param mchKey KEY * @param body ?? * @return ??? */ public static Map<String, Object> payOrder(String outTradeNo, String openId, BigDecimal cash, String appId, String mchId, String mchKey, String body) { String propertiesUtil = "";//-PropertiesUtil.notifyUrl String nonceStr = createNoncestr(); String total = String.valueOf(cash.multiply(new BigDecimal(100)).intValue()); // HTTPSRequest.setSslsf(mchId);???mchId.p12?? String signFirst = getSign(nonceStr, outTradeNo, body, total, propertiesUtil, "JSAPI", openId, "127.0.0.1", appId, mchId, mchKey); Map<String, String> prepay = prepay(nonceStr, outTradeNo, body, total, "JSAPI", openId, "127.0.0.1", signFirst, appId, mchId, mchKey); String retCd = prepay.get("return_code"); String prepayId = ""; if (retCd.equals("SUCCESS")) { String resultCd = prepay.get("result_code"); if (resultCd.equals("SUCCESS")) { prepayId = prepay.get("prepay_id"); } } String packages = "prepay_id=" + prepayId; String timeStamp = String.valueOf(System.currentTimeMillis() / 1000L); String signType = "MD5"; Map<String, String> parameters = new HashMap<String, String>(); parameters.put("appId", appId); parameters.put("timeStamp", timeStamp); parameters.put("nonceStr", nonceStr); parameters.put("package", packages); parameters.put("signType", signType); String sign = getSign(parameters, mchKey); Map<String, Object> jsonMap = new LinkedHashMap<String, Object>(); jsonMap.put("appId", appId); jsonMap.put("timeStamp", timeStamp); jsonMap.put("nonceStr", nonceStr); jsonMap.put("package", packages); jsonMap.put("signType", signType); jsonMap.put("paySign", sign); // String totalFee = String.valueOf(chargeOrderCash.multiply(new BigDecimal(100)).intValue()); return jsonMap; }
From source file:org.apache.hadoop.hbase.coprocessor.TestBigDecimalColumnInterpreter.java
/** * A set up method to start the test cluster. AggregateProtocolImpl is registered and will be * loaded during region startup.//from w w w. ja va 2s . c om * @throws Exception */ @BeforeClass public static void setupBeforeClass() throws Exception { conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, "org.apache.hadoop.hbase.coprocessor.AggregateImplementation"); util.startMiniCluster(2); HTable table = util.createTable(TEST_TABLE, TEST_FAMILY); util.createMultiRegions(util.getConfiguration(), table, TEST_FAMILY, new byte[][] { HConstants.EMPTY_BYTE_ARRAY, ROWS[rowSeperator1], ROWS[rowSeperator2] }); /** * The testtable has one CQ which is always populated and one variable CQ for each row rowkey1: * CF:CQ CF:CQ1 rowKey2: CF:CQ CF:CQ2 */ for (int i = 0; i < ROWSIZE; i++) { Put put = new Put(ROWS[i]); put.setDurability(Durability.SKIP_WAL); BigDecimal bd = new BigDecimal(i); put.add(TEST_FAMILY, TEST_QUALIFIER, Bytes.toBytes(bd)); table.put(put); Put p2 = new Put(ROWS[i]); put.setDurability(Durability.SKIP_WAL); p2.add(TEST_FAMILY, Bytes.add(TEST_MULTI_CQ, Bytes.toBytes(bd)), Bytes.toBytes(bd.multiply(new BigDecimal("0.10")))); table.put(p2); } table.close(); }
From source file:edu.ku.brc.specify.config.LatLonConverter.java
public static BigDecimal convertDDMMMMStrToDDDDBD(final String str, final String direction) { BigDecimal bd = convertDDMMMMStrToDDDDBD(str); if (isNegative(direction)) { return bd.multiply(minusOne); }//from w w w .ja v a 2 s .com return bd; }
From source file:adalid.commons.util.ObjUtils.java
public static BigDecimal product(Object... objects) { BigDecimal result = BigDecimal.ONE; BigDecimal multiplicand;/*from w ww.j a va 2 s . c o m*/ int i = 0; for (Object obj : objects) { multiplicand = NumUtils.numberToBigDecimal(obj); if (multiplicand == null) { return null; } i++; result.multiply(multiplicand); } return i > 1 ? result : null; }
From source file:edu.ku.brc.specify.config.LatLonConverter.java
/** * @param str/* w ww . ja v a 2s . c o m*/ * @return */ public static BigDecimal convertDirectionalDDDDToDDDD(final String str) { String[] parts = StringUtils.split(str, " d'\"" + DEGREES_SYMBOL); String dir = null; if (parts.length < 2) { parts[0] = parts[0].replaceAll("[NSEW]", ""); int beginIndex = str.indexOf(parts[0]) + parts[0].length(); dir = str.substring(beginIndex, beginIndex + 1); } else { dir = parts[1].substring(0, 1); } double p0 = parseDouble(parts[0]); BigDecimal val = new BigDecimal(p0); if (isNegative(dir)) { val = val.multiply(minusOne); } return val; }
From source file:edu.ku.brc.specify.config.LatLonConverter.java
public static BigDecimal convertDDMMSSStrToDDDDBD(final String str, final String direction) { BigDecimal bd = convertDDMMSSStrToDDDDBD(str); if (isNegative(direction)) { return bd.multiply(minusOne); }// w w w .jav a2 s . c om return bd; }
From source file:edu.ku.brc.specify.config.LatLonConverter.java
public static BigDecimal convertDDDDStrToDDDDBD(final String str, final String direction) { String val = StringUtils.replace(StringUtils.replace(str, decimalSep, ""), "-", ""); if (!StringUtils.isNumeric(val)) { return null; }/* ww w . ja v a2 s.co m*/ BigDecimal bd = parseDoubleToBigDecimal(str); if (isNegative(direction)) { return bd.multiply(minusOne); } return bd; }
From source file:edu.ku.brc.specify.config.LatLonConverter.java
public static BigDecimal convertDDMMMMStrToDDDDBD(final String str) { String[] parts = StringUtils.split(str, " dm'\"" + DEGREES_SYMBOL); double p0 = parseDouble(parts[0]); boolean neg = false; if (p0 < 0) { p0 = p0 * -1;/*from w w w. j a va2s . co m*/ neg = true; } Double p1 = parseDouble(parts[1]); if (p1 != null) { BigDecimal val = new BigDecimal(p0 + (p1 / 60.0)); if (neg) { val = val.multiply(minusOne); } return val; } return null; }
From source file:edu.ku.brc.specify.config.LatLonConverter.java
public static BigDecimal convertDDMMSSStrToDDDDBD(final String str) { String[] parts = StringUtils.split(str, " d'\"" + DEGREES_SYMBOL); if (parts.length != 3) { return null; }/*from ww w . ja va 2 s . com*/ double p0 = parseDouble(parts[0]); boolean neg = false; if (p0 < 0) { p0 = p0 * -1; neg = true; } double p1 = parseDouble(parts[1]); double p2 = parseDouble(parts[2]); BigDecimal val = new BigDecimal(p0 + ((p1 + (p2 / 60.0)) / 60.0)); if (neg) { val = val.multiply(minusOne); } return val; }