import com.oracle.e1.common.OrchestrationAttributes; import java.text.SimpleDateFormat; HashMap < String, Object > main(OrchestrationAttributes orchAttr, HashMap inputMap) { HashMap < String, Object > returnMap = new HashMap < String, Object > (); if (inputMap.get("CreditLimit") != null && inputMap.get("UnpaidAmount") != null) { try { BigDecimal creditLimit = new BigDecimal((String) inputMap.get("CreditLimit")); BigDecimal unpaidAmt = new BigDecimal((String) inputMap.get("UnpaidAmount")); if (creditLimit > 0) { BigDecimal usage = unpaidAmt.divide(creditLimit, 3, BigDecimal.ROUND_HALF_UP); if (usage != null) { usage = usage.multiply(new BigDecimal(100)); returnMap.put("UsagePercent", String.valueOf(usage.doubleValue())); } } else if (unpaidAmt > 0) { returnMap.put("UsagePercent", "100.0"); } } catch (Exception e) { //cannot format the numbers just set it to zero returnMap.put("UsagePercent", "0"); } } else { //no data sent in returnMap.put("UsagePercent", "0"); } return returnMap; }