Can you tell me how to achieve this in android:
Transform a String
into a float
as in:
String temp="1,000,00"
to
float f=100f
I had already gone through links. Getting this exception :
java.lang.NumberFormatException: Invalid float: ""
Can you tell me how to achieve this in android:
Transform a String
into a float
as in:
String temp="1,000,00"
to
float f=100f
I had already gone through links. Getting this exception :
java.lang.NumberFormatException: Invalid float: ""
Have you tried like this:
String s = "100";
float f = Float.parseFloat(s);
and make sure that the String you are parsing is indeed a float
and is not null
or empty
You should be using the Float class's parseFloat method.
It sounds like the problem is with the actual string you are using though - can you post that?
Use the Float class.
// String to Float
float temp = Float.parseFloat("100f");
// Float to String:
String str = Float.toString(100.0f);