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
Post a Comment