我需要有关如何在更新数据库之前从字符串中删除$符号的帮助目前在我的应用程序中,默认情况下从结尾添加$作为第一个字符。我需要知道如何删除它,因为我在更新数据库时遇到了Big Decimal错误。
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);
答案 0 :(得分:1)
你可以尝试两件事。
str = str.replace("$","");
OR
str = str.substring(1);
原因
你只想删除第一个字符。