To convert a float
to long
you could just use a casting
(long) custom.getTemperature()
However, if all you have is a String representing a floating point number, you may want to change your convert function, to receive a float instead.-
public static int convertCelsiusToFahrenheit(float celcious){
return Math.round(celcious * 9.0f / 5.0f + 32);
}
And pass
Float.parseFloat(custom.getTemperature())
Don't forget to divide 9.0f / 5.0f
instead of 9 / 5
, as the last one is an integer division and will always return 1.
.
stackoverflow.comm
No comments:
Post a Comment