0

I need help on how to remove a $ signs from a string before updating DB Currently in my application the from end on default adds a $ as a first character. I need to know how I can remove that because I get the Big Decimal error when updating DB.

String postagePaid = (String) request.getParameter("tPostagePaid");
            String insuranceFees = (String) request.getParameter("tInsuranceFees");
            String registeredFees = (String) request.getParameter("tRegisteredFees");
            String codFees = (String) request.getParameter("tCODFees");
            String insRegisteredCODFees = (String) request.getParameter("tInsuranceFees");
            System.out.println("insurance Fee: " + insuranceFees);
            if (postagePaid != null && !insuranceFees.isEmpty()) { // postage paid amount
                claim.setClPostagePaidAmt(new BigDecimal(postagePaid));
            }
            if (insuranceFees != null && !insuranceFees.isEmpty()) { // Insurance Fees
                claim.setClInsuranceFee(new BigDecimal(insuranceFees));
            }
            if (registeredFees != null && !insuranceFees.isEmpty()) { // Registered Fees
                claim.setClRegisteredFee(new BigDecimal(registeredFees));
            }
            if (codFees != null && !insuranceFees.isEmpty()) { // COD Fees
                claim.setClCodFee(new BigDecimal(codFees));
            }
            claim.setClInsRegCodAmt(null);
user2149910
  • 87
  • 3
  • 12
  • 1
    http://stackoverflow.com/questions/4576352/java-remove-all-occurrences-of-char-from-string – Pienterekaak Sep 04 '14 at 15:43
  • so what is the actual problem? did u try anything to replace like `yourStr.replaceAll("\\$","")` or anything? – SparkOn Sep 04 '14 at 15:45
  • 1
    Better to just do `yourStr.replace("$", "")` and avoid used regexes when they aren't needed. – David Conrad Sep 04 '14 at 15:52
  • @SparkOn I was trying .replace('$', '') but it didnt work now im trying .replace("$", "") lets see if it works. – user2149910 Sep 04 '14 at 16:13
  • @user2149910 does it even compiled? you really need to learn some basics http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replace(java.lang.CharSequence, java.lang.CharSequence) – SparkOn Sep 04 '14 at 16:16

1 Answers1

1

You can try two things.

str = str.replace("$","");

OR

str = str.substring(1);

REASON
You just want to remove the first character.

Niru
  • 732
  • 5
  • 9