In my application, if I input a number into 'invoiceAmount' say '1234.5' The app works fine and is able to handle this. If I try say '1234.55' I receive an error. (Sadly the error message is unhelpful to provide here).
To try and get around this, I have added the 'BigDecimal' section into this segment of code:
@RequestMapping(value="makeRetainedInvoicePlacement", method = {RequestMethod.POST, RequestMethod.GET})
public void makeRetainedInvoicePalcement(HttpServletRequest req, HttpServletResponse resp, Model model) throws IOException {
String jobOrderID = req.getParameter("jobOrderID");
String dateFormat = req.getParameter("dateFormat");
String invoiceDateStr = req.getParameter("invoiceDate");
String invoiceAmountDec = req.getParameter("invoiceAmount");
String retainerStageInfo = req.getParameter("retainerStageInfo");
Date invoiceDate = Utility.parseStringToDate(invoiceDateStr, dateFormat);
BigDecimal invoiceAmount = Utility.parseBigDecimal(invoiceAmountDec);
Integer placementID = jobService.saveInvoicePlacement(jobOrderID, invoiceAmount, retainerStageInfo, invoiceDate);
Whenever I try to build my app, I am met with: java.math.BigDecimal cannot be converted to java.lang.String
Basically my app creates a placement elsewhere and sets it into a custom field:
placement.setCustomBillRate5(Utility.parseBigDecimal(invoiceAmount));
I hope someone can help.