java - How to get phone contact without country code? -


i can contact number phone. want know how remove country code it. if user has phone number country code(+91-9876543210), need phone number without prefixed country code(9876543210).

thanks in advance.

i'd suggest use libphonenumber parse phone numbers easily. can split country code , phone number in way.

try {     // phone must begin '+'     phonenumberutil phoneutil = phonenumberutil.getinstance();     phonenumber.phonenumber numberproto = phoneutil.parse("+91-9876543210", "");     int countrycode = numberproto.getcountrycode();     long nationalnumber = numberproto.getnationalnumber();     log.i("code", "code " + countrycode);     log.i("code", "national number " + nationalnumber); } catch (numberparseexception e) {     system.err.println("numberparseexception thrown: " + e.tostring()); } 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -