In Java, I am trying to parse a string of format "0.##" to a float. The string should always have 2 decimal places.
public ArrayList getFixRateDetails (String merchantccy,String paymodetype,String amount)
{
String returnAmt ="";
ArrayList list= new ArrayList();
float value=-1;
try {
NiCurrencyConverterProcessor nicc= new NiCurrencyConverterProcessor();
list=nicc.getFixRateDetails(merchantccy,paymodetype);
Float i = (Float.parseFloat((String) list.get(0)));
Float j = (Float.parseFloat(amount));
value=i*j;
list.set(0, value);
list.add(2, i);
GenericExceptionLog.log("PayPalUtility.java : In getFixRateDetails() : value:"+list,"paymenttarasectionsevlet111");
DecimalFormat df = new DecimalFormat("0.00");
String ReturnAmt = df.format(returnAmt);
returnAmt=String.valueOf(value).trim();
GenericExceptionLog.log("PayPalUtility.java : In getFixRateDetails() : value:"+returnAmt,"paymenttarasectionsevlet222");
} catch (Throwable t) {
GenericAsyncLogger.Logger(t,"ERROR","DB","Transaction","MIGSTxnUtility.java","postingAmtConversion()","NA","NA","","","paymenttarasectionsevlet");
//GenericExceptionLog.exceptionJava(t,"postingAmtConversion()", "MIGSTxnUtility");
}
return list;
}
}