Skip to main content
1 of 5
eatSleepCode
  • 327
  • 1
  • 2
  • 9

Optimization string related code

I have written this block its working fine but is it optimized? I am getting currency in format 1.234,25 .

public static String convertCurrency(String value, String exchangeCurrencyId)
{
    java.text.NumberFormat format = null;
    value = value.replaceAll("\\.", ",");
    char[] chars = value.toCharArray();
    chars[value.lastIndexOf(',')] = '.';
    value = new String(chars);
    value = value.replaceAll(",", "");
    Double price = Double.valueOf(value);
    price = price * (50); //exchange rate

    return price.toString();
}
eatSleepCode
  • 327
  • 1
  • 2
  • 9