how to convert a String value 512m into integer value 512? [closed]

str.replace("\\D", ""); 

will remove all non-digit characters from the string, then you can just parse it:

Integer.parseInt(str);

Leave a Comment