I'm facing the problem with NumberFormatException
. For input string for the French language. When I choose English / Spanish everything works fine! But when I choose French immediately it crashes and shows NFException
.
public void TemperatureCurrentLevel(DosageCalculatorInputDto dosagecalculatorinput, DosageCalculatorResponseDto dosageCalculatorResponseDto) {
double temp = dosagecalculatorinput.getTemperatureNow();
Log.e("temp value", ""+Double.parseDouble(String.format("%.2f", Math.pow(temp, 3))));
double power3 = Double.parseDouble(String.format("%.2f", Math.pow(temp, 3)));
double power2 = Double.parseDouble(String.format("%.2f", Math.pow(temp, 2)));
Double result = (-0.0000005 * power3 + 0.00006 * power2 + 0.0117 * temp - 0.4116);
Log.i("teja1", "temperature factor current " + Double.parseDouble(String.format("%.3f", result)));
dosageCalculatorResponseDto.setTemparatureFactoreCurrent( result);
}
Logcat:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.elitecrest.orenda/com.elitecrest.orenda.MainActivity}: java.lang.NumberFormatException: For input string: "512000,00"
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2721)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2782)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1521)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6228)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
Caused by: java.lang.NumberFormatException: For input string: "512000,00"
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1306)
at java.lang.Double.parseDouble(Double.java:547)
at com.elitecrest.orenda.utils.FormulationClass.TemperatureCurrentLevel(FormulationClass.java:64)
I'm facing problem with power3
value. Its value is 512000.0 for English / Spanish, but 512000,00 for French.