Package java.math

Examples of java.math.BigDecimal.toPlainString()


        ctx.put("finAccountId", "TESTACCOUNT1");
        ctx.put("amount", new BigDecimal("100.00"));
        ctx.put("userLogin", userLogin);
        Map resp = dispatcher.runSync("finAccountDeposit", ctx);
        BigDecimal balance = (BigDecimal) resp.get("balance");
        assertEquals(balance.toPlainString(), "100.00");
    }

    public void testWithdraw() throws Exception {
        Map ctx = FastMap.newInstance();
        ctx.put("finAccountId", "TESTACCOUNT1");
View Full Code Here


            }
            // (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

        Element packagingTypeElement = UtilXml.addChildElement(packageElement, "PackagingType", requestDoc);
        UtilXml.addChildElementValue(packagingTypeElement, "Code", "00", requestDoc);
        UtilXml.addChildElementValue(packagingTypeElement, "Description", "Unknown PackagingType", requestDoc);
        UtilXml.addChildElementValue(packageElement, "Description", "Package Description", requestDoc);
        Element packageWeightElement = UtilXml.addChildElement(packageElement, "PackageWeight", requestDoc);
        UtilXml.addChildElementValue(packageWeightElement, "Weight", packageWeight.toPlainString(), requestDoc);
        //If product is in shippable Package then it we should have one product per packagemap
        if (packageMap.size() ==1) {
            Iterator<String> i = packageMap.keySet().iterator();
            String productId = i.next();
            Map<String, Object> productInfo = ShipmentWorker.getProductItemInfo(shippableItemInfo, productId);
View Full Code Here

    {
        public void write(Object obj, boolean showType, Writer out) throws IOException
        {
            BigDecimal big = (BigDecimal) obj;
            out.write("\"value\":\"");
            out.write(big.toPlainString());
            out.write('"');
        }

        public boolean hasPrimitiveForm() { return true; }
View Full Code Here

        public void writePrimitiveForm(Object o, Writer out) throws IOException
        {
            BigDecimal big = (BigDecimal) o;
            out.write('"');
            out.write(big.toPlainString());
            out.write('"');
        }
    }

    public static class StringBuilderWriter implements JsonClassWriter
View Full Code Here

    {
        public void write(Object obj, boolean showType, Writer out) throws IOException
        {
            BigDecimal big = (BigDecimal) obj;
            out.write("\"value\":\"");
            out.write(big.toPlainString());
            out.write('"');
        }

        public boolean hasPrimitiveForm() { return true; }
View Full Code Here

        public void writePrimitiveForm(Object o, Writer out) throws IOException
        {
            BigDecimal big = (BigDecimal) o;
            out.write('"');
            out.write(big.toPlainString());
            out.write('"');
        }
    }

    public static class StringBuilderWriter implements JsonClassWriter
View Full Code Here

   */
  public void testToPlainStringNegNegExp() {
    String a = "-123809648392384754573567356745735.63567890295784902768787678287E-100";
    BigDecimal aNumber = new BigDecimal(a);
    String result = "-0.000000000000000000000000000000000000000000000000000000000000000000012380964839238475457356735674573563567890295784902768787678287";
    assertTrue("incorrect value", aNumber.toPlainString().equals(result));
  }

  /**
   * Convert a negative BigDecimal with a positive exponent to a plain string
   * representation; scale == 0.
View Full Code Here

   */
  public void testToPlainStringNegPosExp() {
    String a = "-123809648392384754573567356745735.63567890295784902768787678287E100";
    BigDecimal aNumber = new BigDecimal(a);
    String result = "-1238096483923847545735673567457356356789029578490276878767828700000000000000000000000000000000000000000000000000000000000000000000000";
    assertTrue("incorrect value", aNumber.toPlainString().equals(result));
  }

  /**
   * Convert a positive BigDecimal with a negative exponent to a plain string
   * representation; scale == 0.
View Full Code Here

   */
  public void testToPlainStringPosNegExp() {
    String a = "123809648392384754573567356745735.63567890295784902768787678287E-100";
    BigDecimal aNumber = new BigDecimal(a);
    String result = "0.000000000000000000000000000000000000000000000000000000000000000000012380964839238475457356735674573563567890295784902768787678287";
    assertTrue("incorrect value", aNumber.toPlainString().equals(result));
  }

  /**
   * Convert a negative BigDecimal with a negative exponent to a plain string
   * representation; scale == 0.
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.