Import Org.apache.commons.lang.stringutils;import Java.util.hashmap;import Java.util.map;public class phonenumberutils {private static map<string,integer> Region_country_map = new hashmap<> (); private static map<integer,string> Country_region_map = new hashmap<> (); static {Initcountrycodemap (); } private static void Initcountrycodemap () {String countrycodemapstring = "ad:376,ae:971,af:93,ag:1268,ai:1264, al:355,am:374,ao:244,ar:54,at:43,au:61,az:994,bb:1246,bd:880,be:32,bf:226,bg:359,bh:973,bi:257,bj:229,bm:1441, Bn:673,bo:591,br:55,bs:1242,bw:267,by:375,bz:501,ca:1,cf:236,cg:242,ch:41,ck:682,cl:56,cm:237,cn:86,co:57,cr : 506,CU:53,CY:357,CZ:420,DE:49,DJ:253,DK:45,DO:1890,DZ:213,EC:593,EE:372,EG:20,ES:34,ET:251,FI:358,FJ:679,FR : 33,ga:241,gb:44,gd:1809,ge:995,gf:594,gh:233,gi:350,gm:220,gn:224,gr:30,gt:502,gu:1671,gy:592,hk:852,hn:504, Ht:509,hu:36,id:62,ie:353,il:972,in:91,iq:964,ir:98,is:354,it:39,jm:1876,jo:962,jp:81,ke:254,kg:331,kh: 855,kp:850,kr:82,kw:965,kz:327,la:856,lb:961,lc:1758,lc:1758,li:423,lk:94,lr:231,ls:266,lt:370,lu:352,lv:371, Ly:218,ma:212,mc:377,md:373,mg:261,ml:223,mm:95,mn:976,mo:853,ms:1664,mt:356,mu:230,mv:960,mw:265,mx:52,my:60, Mz:258,na:264,ne:227,ng:234,ni:505,nl:31,no:47,np:977,nr:674,nz:64,om:968,pa:507,pe:51,pf:689,pg:675,ph:63,pk : 92,pl:48,pr:1787,pt:351,py:595,qa:974,ro:40,ru:7,sa:966,sb:677,sc:248,sd:249,se:46,sg:65,si:386,sk:421,sl:232 , sm:378,sn:221,so:252,sr:597,st:239,sv:503,sy:963,sz:268,td:235,tg:228,th:66,tj:992,tm:993,tn:216,to:676,tr:90 , tt:1809,tw:886,tz:255,ua:380,ug:256,us:1,uy:598,uz:233,vc:1784,vc:1784,ve:58,vn:84,ye:967,yu:381,za:27,zm:260 , zr:243,zw:263, "; string[] ss = Countrycodemapstring.split (","); for (String s:ss) {try {if (! Stringutils.isblank (s)) {string[] aa = S.split (":"); if (aa.length = = 2) {String regincode = aa[0]; Integer CountryCode =Integer.valueof (Aa[1].trim ()); Region_country_map.put (Regincode,countrycode); Country_region_map.put (Countrycode,regincode); }}}catch (Exception e) {}}} public static String GETREGINFORCOUNTRYC Ode (Integer CountryCode) {return country_region_map.get (CountryCode); public static int Getcountrycodeforregion (String region) {region = Region.touppercase (); Return Region_country_map.get (region); }}
Country code and Regincode mapping relationship