How to analyze the numeric values ​​of a string?

advertisements

How do I convert String in form xx:yy into integer form xxyy or float form xx.yy

For example If I have the following string.

String x = "10:30"

How do I get integer 1030 or float value 10.30 ?


String xInt = x.replace(":","");
Integer.parseInt(xInt);
String xFloat = x.replace(":",".");
Float.parseFloat(xFloat);