public ArrayList<PriceTag> calculatePrice( Category category, String priceBreaks, double currencyINR, String manuFacturerPartNumber, long productCatalogId, long supplierId, String sku) { ArrayList<PriceTag> priceTagImplsList = new ArrayList<PriceTag>(); double cur_markup = category.getCurrencyMarkup(); double dty = category.getDuty(); double hfin = category.getHfi(); double vt = category.getVat(); hfin = hfin / 100; dty = dty / 100; vt = vt / 100; // Splitting the whole string in to two parts String[] temp = priceBreaks.split("USD"); System.out.println("priceBreaks" + priceBreaks); System.out.println("temp.length" + temp.length); PriceTag priceTagImpl = null; if (temp.length != 1) { for (int j1 = 0; j1 < temp.length; j1++) { priceTagImpl = new PriceTag(); int rup = j1; String semi = temp[j1]; try { System.out.println("Semi" + semi); String[] sem = semi.split(java.util.regex.Pattern.quote("$")); String ss = ""; System.out.println(sem[1]); String[] semi1 = sem[1].split(java.util.regex.Pattern.quote(",")); if (semi1.length < 2) { ss = semi1[0]; } else { ss = semi1[0] + semi1[1]; } double dolToRup; if (ss != null) { // semi1[1] != null) { dolToRup = Double.parseDouble(ss); // semi1[1]); dolToRup = dolToRup * currencyINR; dolToRup = dolToRup + cur_markup; // adding dolToRup = dolToRup + (dolToRup * dty); dolToRup = dolToRup + (dolToRup * hfin); String temp11 = String.format("%.2f", dolToRup); ss = temp11; if (rup == 0) {} String type; Double dd = vt * 100; String temp1111 = String.format("%.2f", dd); if (dty == 0 && vt == 0) { type = "Exclusive of Duty & VAT"; } else { type = "Inclusive of Duty + " + temp1111 + "% VAT as Applicable"; } priceTagImpl.setQuentity(Integer.parseInt(sem[0])); priceTagImpl.setSalePrice(Float.parseFloat(ss)); priceTagImpl.setRetailPrice(Float.parseFloat(ss)); priceTagImpl.setTax(type); } } catch (Exception e) { e.printStackTrace(); } priceTagImpl.setSku(sku); long priceTagId = mouserApiDao.getPriceTagId(supplierId, productCatalogId, priceTagImpl.getQuentity()); priceTagImpl.setSupplierId(supplierId); priceTagImpl.setProductCatalogId(productCatalogId); if (priceTagId == 0) { mouserApiDao.insertPriceTag(priceTagImpl); } else { priceTagImpl.setPriceTagId(priceTagId); mouserApiDao.updatePriceTag(priceTagImpl); } priceTagImplsList.add(priceTagImpl); } } return priceTagImplsList; }