2014-09-04 75 views
0

我需要关于如何在更新数据库之前从字符串中删除$符号的帮助目前在我的应用程序中,默认情况下从结尾添加$作为第一个字符。我需要知道如何删除它,因为更新数据库时遇到大十进制错误。

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); 
+1

http://stackoverflow.com/questions/4576352/java-remove-all-occurrences-of-char-from-string – Pienterekaak 2014-09-04 15:43:52

+0

那么实际的问题是什么?你是否尝试过任何东西来代替'yourStr.replaceAll(“\\ $”,“”)“或任何东西? – SparkOn 2014-09-04 15:45:25

+1

只需执行'yourStr.replace(“$”,“”)'',避免在不需要时使用正则表达式。 – 2014-09-04 15:52:26

回答

1

您可以尝试两件事。

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

OR

str = str.substring(1); 

原因
你只是要删除的第一个字符。

相关问题