Package java.math

Examples of java.math.BigDecimal.toPlainString()


            }
            // (packageWeight % 1) * 16 (Rounded up to 0 dp)
            BigDecimal weightOunces = packageWeight.remainder(BigDecimal.ONE).multiply(new BigDecimal("16")).setScale(0, BigDecimal.ROUND_CEILING);
           
            UtilXml.addChildElementValue(packageElement, "Pounds", weightPounds.toPlainString(), requestDocument);
            UtilXml.addChildElementValue(packageElement, "Ounces", weightOunces.toPlainString(), requestDocument);

            // TODO: handle other container types, package sizes, and machinable packages
            // IMPORTANT: Express or Priority Mail will fail if you supply a Container tag: you will get a message like
            // Invalid container type. Valid container types for Priority Mail are Flat Rate Envelope and Flat Rate Box.
            /* This is an official response from the United States Postal Service:
View Full Code Here


        encoder.add("CURRENCYCODE", orh.getCurrency());
        BigDecimal grandTotal = orh.getOrderGrandTotal();
        BigDecimal shippingTotal = orh.getShippingTotal().setScale(2, BigDecimal.ROUND_HALF_UP);
        BigDecimal taxTotal = orh.getTaxTotal().setScale(2, BigDecimal.ROUND_HALF_UP);
        BigDecimal subTotal = grandTotal.subtract(shippingTotal).subtract(taxTotal).setScale(2, BigDecimal.ROUND_HALF_UP);
        encoder.add("ITEMAMT", subTotal.toPlainString());
        encoder.add("SHIPPINGAMT", shippingTotal.toPlainString());
        encoder.add("TAXAMT", taxTotal.toPlainString());

        NVPDecoder decoder = null;
        try {
View Full Code Here

      return null;
    }
    if (val instanceof BigDecimal && hfsType == HCatFieldSchema.Type.STRING) {
      BigDecimal bd = (BigDecimal) val;
      if (bigDecimalFormatString) {
        return bd.toPlainString();
      } else {
        return bd.toString();
      }
    }
    Number n = (Number) val;
View Full Code Here

      String str = null;
      // TF:Mar 18, 2010:Changed these to use the constant
      BigDecimal result = BigDecimal.ZERO;
      if (source1.compareTo(BigDecimal.ZERO) > 0 ) {
           result = source1.divide(source2, scale+2, RoundingMode.HALF_UP);
           str = result.toPlainString();
           int dotindex = str.indexOf('.') + 1;
           String resultString = str.substring(0,(dotindex+scale));
           result = new BigDecimal(resultString);          
      }else{
        result = source1;
View Full Code Here

            }catch( Exception e ){
                //e.printStackTrace();
            }
        }else if( toType == String.class ){
          BigDecimal value = (BigDecimal)o;
            return value.toPlainString();
        }
        return null;
    }

}
View Full Code Here

      String str = null;
      // TF:Mar 18, 2010:Changed these to use the constant
      BigDecimal result = BigDecimal.ZERO;
      if (source1.compareTo(BigDecimal.ZERO) > 0 ) {
           result = source1.divide(source2, scale+2, RoundingMode.HALF_UP);
           str = result.toPlainString();
           int dotindex = str.indexOf('.') + 1;
           String resultString = str.substring(0,(dotindex+scale));
           result = new BigDecimal(resultString);          
      }else{
        result = source1;
View Full Code Here

      String str = null;
      // TF:Mar 18, 2010:Changed these to use the constant
      BigDecimal result = BigDecimal.ZERO;
      if (source1.compareTo(BigDecimal.ZERO) > 0 ) {
           result = source1.divide(source2, scale+2, RoundingMode.HALF_UP);
           str = result.toPlainString();
           int dotindex = str.indexOf('.') + 1;
           String resultString = str.substring(0,(dotindex+scale));
           result = new BigDecimal(resultString);          
      }else{
        result = source1;
View Full Code Here

      String str = null;
      // TF:Mar 18, 2010:Changed these to use the constant
      BigDecimal result = BigDecimal.ZERO;
      if (source1.compareTo(BigDecimal.ZERO) > 0 ) {
           result = source1.divide(source2, scale+2, RoundingMode.HALF_UP);
           str = result.toPlainString();
           int dotindex = str.indexOf('.') + 1;
           String resultString = str.substring(0,(dotindex+scale));
           result = new BigDecimal(resultString);          
      }else{
        result = source1;
View Full Code Here

            try {
                // BigDecimal constructor can choke on commas (aka grouping separator)
                string = _canonicalizeExponentialBigDecimal (string, fmt);
               
                BigDecimal parsedBigDecimal = new BigDecimal(string);
                String parsedString = parsedBigDecimal.toPlainString();
                DecimalFormat canonicalExponentialFormat =
                        acquireDecimalFormat(Locale.ENGLISH);
                return BigDecimalFormatter.parseBigDecimal(parsedString,
                                                           canonicalExponentialFormat);
            }
View Full Code Here

                throws ParseException
        {
            BigDecimal exponentialAmount = matcher.getAmount();
            String exponentialString = matcher.getExponentialString();
            String completeExponentialString = StringUtil.strcat(
                exponentialAmount.toPlainString(), exponentialString);
            DecimalParseInfo exponentialInfo =
                parseExponentialBigDecimal(completeExponentialString, fmt);
            String exponentialPrefixString = matcher.getPrefixString();
            String exponentialSuffixString = matcher.getSuffixString();
            return new DecimalParseInfo(exponentialInfo.integerDigits,
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.