I could think of the following solutions:
Make sure users cannot enter phone numbers in another format then the numeric format by using regular expression validation and/or an input mask. Do not use an integer value here, because that will remove the zeros in front of the phone number.
Write a Java action that returns the phone number without non-numeric characters.
Example code:
// BEGIN USER CODE
String tmpPhoneNumber = "";
for(int x=0;x<PhoneNumberAllChars.length();x++)
{
int tmpCharNr = (int)PhoneNumberAllChars.charAt(x);
if(tmpCharNr>47&&tmpCharNr<58)
{
tmpPhoneNumber += (char)tmpCharNr;
}
}
if(tmpPhoneNumber.length()==0) return null;
else return tmpPhoneNumber;
// END USER CODE
In general, it is easier (well, if you have little experience with them) and faster to use regular expressions for this kind of string manipulations. See for among other this example.
The oneliner is (untested):
String result = Pattern.compile("[^\\d]+").matcher(originalvalue).replaceAll("");
The regular expression [^\d]+ means: match any sequence (+) of characters ([...]) which are not (^) digits (\d) (the second slash in the regex is required to escape the first one)