import org.apache.commons.lang.StringUtils; public class CountryUtil { /** * 根據國家二字碼獲取國家對應的中文(英文,code) * * @param countryCode * @return * @author Henry(fba02) * @version [版本號, 2019年1月17日] * @see [類、類#方法、類#成員] */ public static String getCountryNameCnEnCodeByCountryCode(String countryCode) { String countryName = null; switch (countryCode) { case "US": countryName = "美國(United State,US)"; break; case "GB": countryName = "英國(United Kingdom,GB)"; break; case "DE": countryName = "德國(Germany,DE)"; break; case "CA": countryName = "加拿大(Canada,CA)"; break; case "JP": countryName = "日本(Japan,JP)"; break; case "ES": countryName = "西班牙(Spain,ES)"; break; case "FR": countryName = "法國(France,FR)"; break; case "IT": countryName = "意大利(Italy,IT)"; break; case "CN": countryName = "中國(China,CN)"; break; case "AT": countryName = "奧地利(Austria,AT)"; break; case "AU": countryName = "澳大利亞(Australian,AU)"; break; case "CH": countryName = "瑞士(Switzerland,CH)"; break; case "EG": countryName = "埃及(Egypt,EG)"; break; case "FI": countryName = "芬蘭(Finland,FI)"; break; case "IN": countryName = "印度(India,IN)"; break; case "IE": countryName = "愛爾蘭(Ireland,IE)"; break; case "ID": countryName = "印度尼西亞(Indonesia,ID)"; break; case "KH": countryName = "柬埔寨(Cambodia,KH)"; break; case "KR": countryName = "韓國(Korea,KR)"; break; case "MX": countryName = "墨西哥(Mexico,MX)"; break; case "NL": countryName = "荷蘭(Holland,NL)"; break; case "NO": countryName = "挪威(Norway,NO)"; break; case "MM": countryName = "緬甸(Burma,MM)"; break; case "PH": countryName = "菲律賓(Philippines,PH)"; break; case "BE": countryName = "比利時(Belgium,BE)"; break; case "GY": countryName = "圭亞那(Guyana,GY)"; break; case "SE": countryName = "瑞典(Sweden,SE)"; break; case "PY": countryName = "巴拉圭(Paraguay,PY)"; break; case "UA": countryName = "烏克蘭(Ukraine,UA)"; break; case "PE": countryName = "祕魯(Peru,PE)"; break; case "AE": countryName = "阿聯酋(United Arab Emirates,AE)"; break; case "VN": countryName = "越南(Vietnam,VN)"; break; case "SO": countryName = "索馬里(Somalia,SO)"; break; case "LA": countryName = "老撾(Laos,LA)"; break; case "KW": countryName = "科威特(Kuwait,KW)"; break; case "MY": countryName = "馬來西亞(Malaysia,MY)"; break; case "DK": countryName = "丹麥(Denmark,DK)"; break; case "PK": countryName = "巴基斯坦(Pakistan,PK)"; break; case "TH": countryName = "泰國(Thailand,TH)"; break; case "HU": countryName = "匈牙利(HUNGARY,HU)"; break; case "LV": countryName = "拉脫維亞(Latvia,LV)"; break; case "RU": countryName = "俄羅斯(Russia,RU)"; break; case "CZ": countryName = "捷克(Czech Republic,CZ)"; break; case "PL": countryName = "波蘭(Poland,PL)"; break; case "BY": countryName = "白俄羅斯(Belarus,BY)"; break; case "LT": countryName = "立陶宛(Lithuania,LT)"; break; case "LU": countryName = "盧森堡(Luxembourg,LU)"; break; case "AD": countryName = "安道爾(Andorra,AD)"; break; case "AG": countryName = "安提瓜(Antigua and Barbuda,AG)"; break; case "RO": countryName = "羅馬尼亞(Romania,RO)"; break; case "AM": countryName = "亞美尼亞(Armenia,AM)"; break; case "CV": countryName = "佛得角(Cape Verde,CV)"; break; case "DZ": countryName = "阿爾及利亞(Algeria,DZ)"; break; case "RT": countryName = "羅塔島(北馬裏亞納羣島)(Rota(Northern Mariana Islands),RT)"; break; case "TL": countryName = "東帝汶(Timor-Leste,TL)"; break; case "MU": countryName = "毛里求斯(Mauritius,MU)"; break; case "ZM": countryName = "贊比亞(Zambia,ZM)"; break; case "BL": countryName = "聖巴泰勒米(St. Barthelemy,BL)"; break; case "SX": countryName = "聖馬丁(瓜德羅普島)(St. Maarten,St. Martin,SX)"; break; case "BH": countryName = "巴林(Bahrain,BH)"; break; case "GM": countryName = "岡比亞(Gambia,GM)"; break; case "MV": countryName = "馬爾代夫(Maldives,MV)"; break; case "CK": countryName = "庫克羣島(Cook Islands,CK)"; break; case "RE": countryName = "留尼汪島(Reunion Island,RE)"; break; case "IQ": countryName = "伊拉克(Iraq,IQ)"; break; case "GD": countryName = "格林納達(Grenada,GD)"; break; case "FM": countryName = "密克羅尼西亞(Micronesia,Federated States of,FM)"; break; case "VE": countryName = "委內瑞拉(Venezuela,VE)"; break; case "NC": countryName = "新喀里多尼亞(New Caledonia,NC)"; break; case "NP": countryName = "尼泊爾(Nepal,NP)"; break; case "MD": countryName = "摩爾多瓦共和國(Moldova,MD)"; break; case "VA": countryName = "梵蒂岡(Vatican City(Italy),VA)"; break; case "GP": countryName = "瓜德羅普島(Guadeloupe,GP)"; break; case "GU": countryName = "關島(Guam,GU)"; break; case "NA": countryName = "納米比亞(Namibia,NA)"; break; case "QA": countryName = "卡塔爾(Qatar,QA)"; break; case "YT": countryName = "馬約特島島(Mayotte,YT)"; break; case "ME": countryName = "黑山(Montenegro,ME)"; break; case "BT": countryName = "不丹(Bhutan,BT)"; break; case "UZ": countryName = "烏茲別克斯坦(Uzbekistan,UZ)"; break; case "WF": countryName = "瓦利斯羣島和富圖納羣島(Wallis & Futuna Islands,WF)"; break; case "JO": countryName = "約旦(Jordan,JO)"; break; case "MK": countryName = "馬其頓(Macedonia(FYROM),MK)"; break; case "BF": countryName = "布基納法索(Burkina Faso,BF)"; break; case "NE": countryName = "尼日爾(Niger,NE)"; break; case "WL": countryName = "威爾士(英國)(Wales(United Kingdom),WL)"; break; case "GE": countryName = "格魯吉亞(Georgia,GE)"; break; case "IS": countryName = "冰島(Iceland,IS)"; break; case "ER": countryName = "厄立特里亞(Eritrea,ER)"; break; case "KM": countryName = "科摩羅(Comoros,KM)"; break; case "SN": countryName = "塞內加爾(Senegal,SN)"; break; case "EE": countryName = "愛沙尼亞(Estonia,EE)"; break; case "MO": countryName = "澳門(Macau,MO)"; break; case "SI": countryName = "斯洛文尼亞(Slovenia,SI)"; break; case "UG": countryName = "烏干達(Uganda,UG)"; break; case "ZW": countryName = "津巴布韋(Zimbabwe,ZW)"; break; case "TD": countryName = "乍得(Chad,TD)"; break; case "GL": countryName = "格陵蘭島(Greenland,GL)"; break; case "AF": countryName = "阿富汗(Afghanistan,AF)"; break; case "CD": countryName = "剛果人民共和國(Congo,Democratic Republic of,CD)"; break; case "MN": countryName = "蒙古(Mongolia,MN)"; break; case "MR": countryName = "毛里塔尼亞(Mauritania,MR)"; break; case "CO": countryName = "哥倫比亞(Colombia,CO)"; break; case "TT": countryName = "特立尼達和多巴哥(Trinidad & Tobago,TT)"; break; case "SF": countryName = "蘇格蘭(Scotland(United Kingdom),SF)"; break; case "CF": countryName = "中非共和國(Central African Republic,CF)"; break; case "GI": countryName = "直布羅陀(Gibraltar,GI)"; break; case "KY": countryName = "開曼羣島(Cayman Islands,KY)"; break; case "NI": countryName = "尼加拉瓜(Nicaragua,NI)"; break; case "TG": countryName = "多哥(Togo,TG)"; break; case "GQ": countryName = "赤道幾內亞(Equatorial Guinea,GQ)"; break; case "KN": countryName = "聖基茨(St. Kitts and Nevis,KN)"; break; case "ZZ": countryName = "托爾托拉島(英屬處女島)(Tortola(British Virgin Islands),ZZ)"; break; case "TZ": countryName = "坦桑尼亞共和國(Tanzania,United Republic of,TZ)"; break; case "KE": countryName = "肯尼亞(Kenya,KE)"; break; case "MH": countryName = "馬紹爾羣島(Marshall Islands,MH)"; break; case "KZ": countryName = "哈薩克斯坦(Kazakhstan,KZ)"; break; case "SA": countryName = "沙特阿拉伯(Saudi Arabia,SA)"; break; case "BN": countryName = "文萊(Brunei Darussalam,BN)"; break; case "SY": countryName = "敘利亞(Syrian Arab Republic,SY)"; break; case "HN": countryName = "洪都拉斯(Honduras,HN)"; break; case "PG": countryName = "巴布亞新幾內亞(Papua New Guinea,PG)"; break; case "HT": countryName = "海地(Haiti,HT)"; break; case "SM": countryName = "聖馬力諾(San Marino,SM)"; break; case "MW": countryName = "馬拉維(Malawi,MW)"; break; case "CM": countryName = "喀麥隆(Cameroon,CM)"; break; case "MG": countryName = "馬達加斯加(Madagascar,MG)"; break; case "PT": countryName = "葡萄牙(Portugal,PT)"; break; case "CR": countryName = "哥斯達黎加(Costa Rica,CR)"; break; case "BM": countryName = "百慕大(Bermuda,BM)"; break; case "SR": countryName = "蘇里南(Suriname,SR)"; break; case "SB": countryName = "所羅門羣島(Solomon Islands,SB)"; break; case "TA": countryName = "大溪地(Tahiti(French Polynesia),TA)"; break; case "CW": countryName = "庫拉索(Curacao,CW)"; break; case "TW": countryName = "中國臺灣(Taiwan,TW)"; break; case "SL": countryName = "塞拉里昂(Sierra Leone,SL)"; break; case "TU": countryName = "特魯克島(密克羅尼西亞聯邦)(Truk(Micronesia,Federated States of),TU)"; break; case "UI": countryName = "聯盟羣島(聖文森特和格林納丁斯羣島)(Union Islands(St. Vincent & the Grenadines),UI)"; break; case "VL": countryName = "聖托馬斯(美屬維爾京羣島)(St. Thomas(U.S. Virgin Islands),VL)"; break; case "NF": countryName = "諾福克(Norfolk Island(Australia),NF)"; break; case "GT": countryName = "危地馬拉(Guatemala,GT)"; break; case "BG": countryName = "保加利亞(Bulgaria,BG)"; break; case "PO": countryName = "波納佩島(密克羅尼西亞聯邦)(Ponape(Micronesia,Federated States of),PO)"; break; case "AW": countryName = "阿魯巴島(Aruba,AW)"; break; case "EC": countryName = "厄瓜多爾(Ecuador,EC)"; break; case "RS": countryName = "塞爾維亞(Serbia,RS)"; break; case "BS": countryName = "巴哈馬(Bahamas,BS)"; break; case "BO": countryName = "玻利維亞(Bolivia,BO)"; break; case "PW": countryName = "帕勞(Palau,PW)"; break; case "KG": countryName = "吉爾吉斯斯坦(Kirghizia(Kyrgyzstan),KG)"; break; case "TC": countryName = "特克斯和凱科斯羣島(Turks & Caicos Islands,TC)"; break; case "LC": countryName = "聖盧西亞(St. Lucia,LC)"; break; case "AZ": countryName = "阿塞拜疆(Azerbaijan,AZ)"; break; case "MT": countryName = "馬耳他(Malta,MT)"; break; case "BI": countryName = "布隆迪(Burundi,BI)"; break; case "AO": countryName = "安哥拉(Angola,AO)"; break; case "CY": countryName = "塞浦路斯(Cyprus,CY)"; break; case "BR": countryName = "巴西(Brazil,BR)"; break; case "WS": countryName = "西薩摩亞(Samoa Western,WS)"; break; case "AX": countryName = "奧蘭羣島(Aland Island(Finland),AX)"; break; case "LR": countryName = "利比里亞(Liberia,LR)"; break; case "FO": countryName = "法羅羣島(Faroe Islands,FO)"; break; case "UV": countryName = "聖約翰(美屬維爾京羣島)(St. John(U.S. Virgin Islands),UV)"; break; case "SG": countryName = "新加坡(Singapore,SG)"; break; case "NG": countryName = "尼日利亞(Nigeria,NG)"; break; case "PA": countryName = "巴拿馬(Panama,PA)"; break; case "DJ": countryName = "吉布提(Djibouti,DJ)"; break; case "SZ": countryName = "斯威士蘭(Swaziland,SZ)"; break; case "DO": countryName = "多米尼加共和國(Dominican Republic,DO)"; break; case "KO": countryName = "摩斯雷(密克羅尼西亞聯邦)(Kosrae(Micronesia,Federated States of),KO)"; break; case "MZ": countryName = "莫桑比克(Mozambique,MZ)"; break; case "AS": countryName = "美國薩摩亞羣島(American Samoa,AS)"; break; case "UY": countryName = "烏拉圭(Uruguay,UY)"; break; case "KT": countryName = "科特迪瓦共和國(Republic Of Ivory Coast,KT)"; break; case "AL": countryName = "阿爾巴尼亞(Albania,AL)"; break; case "CG": countryName = "剛果(Congo,CG)"; break; case "AI": countryName = "安圭拉(Anguilla,AI)"; break; case "RW": countryName = "盧旺達(Rwanda,RW)"; break; case "GR": countryName = "希臘(Greece,GR)"; break; case "BW": countryName = "博茨瓦納(Botswana,BW)"; break; case "HR": countryName = "克羅地亞(Croatia,HR)"; break; case "SC": countryName = "塞舌爾(Seychelles,SC)"; break; case "NZ": countryName = "新西蘭(New Zealand,NZ)"; break; case "PF": countryName = "法屬波利尼西亞(French Polynesia,PF)"; break; case "ML": countryName = "馬裏(Mali,ML)"; break; case "VU": countryName = "瓦努阿圖(Vanuatu,VU)"; break; case "MP": countryName = "北馬裏亞納羣島(Northern Mariana Islands,MP)"; break; case "TR": countryName = "土耳其(Turkey,TR)"; break; case "BA": countryName = "波斯尼亞黑塞哥維那(Bosnia and Herzegovina,BA)"; break; case "LY": countryName = "利比亞(Libyan Arab Jamahiriya,LY)"; break; case "SV": countryName = "薩爾瓦多(El Salvador,SV)"; break; case "TN": countryName = "突尼斯(Tunisia,TN)"; break; case "SW": countryName = "聖克里斯托佛島及尼維斯島(St. Christopher(St. Kitts),SW)"; break; case "AR": countryName = "阿根廷(Argentina,AR)"; break; case "YE": countryName = "也門(Yemen,Republic of,YE)"; break; case "TJ": countryName = "塔吉克斯坦(Tajikistan,TJ)"; break; case "GA": countryName = "加蓬(Gabon,GA)"; break; case "FJ": countryName = "斐濟(Fiji,FJ)"; break; case "GN": countryName = "幾內亞(Guinea,GN)"; break; case "GH": countryName = "加納(Ghana,GH)"; break; case "BD": countryName = "孟加拉國(Bangladesh,BD)"; break; case "TV": countryName = "圖瓦盧(Tuvalu,TV)"; break; case "YA": countryName = "雅浦(密克羅尼西亞聯邦)(Yap(Micronesia,Federated States of),YA)"; break; case "LI": countryName = "列支敦士登(Liechtenstein,LI)"; break; case "SP": countryName = "塞班島(Saipan(Northern Mariana Islands),SP)"; break; case "LB": countryName = "黎巴嫩(Lebanon,LB)"; break; case "MQ": countryName = "馬提尼克島(Martinique,MQ)"; break; case "ZA": countryName = "南非(South Africa,ZA)"; break; case "BJ": countryName = "貝寧(Benin,BJ)"; break; case "OM": countryName = "阿曼(Oman,OM)"; break; case "TO": countryName = "湯加(Tonga,TO)"; break; case "SK": countryName = "斯洛伐克(Slovakia,SK)"; break; case "BB": countryName = "巴巴多斯(Barbados,BB)"; break; case "MA": countryName = "摩洛哥(Morocco,MA)"; break; case "IL": countryName = "以色列(Israel,IL)"; break; case "LK": countryName = "斯里蘭卡(Sri Lanka,LK)"; break; case "BQ": countryName = "博內爾(Bonaire,St. Eustatius,Saba,BQ)"; break; case "PR": countryName = "波多黎各(Puerto Rico,PR)"; break; case "MS": countryName = "蒙特塞拉特(Montserrat,MS)"; break; case "TM": countryName = "土庫曼斯坦(Turkmenistan,TM)"; break; case "KI": countryName = "基里巴斯(Kiribati,KI)"; break; case "GW": countryName = "幾內亞比紹(Guinea-Bissau,GW)"; break; case "IC": countryName = "加那利羣島(Canary Islands(Spain),IC)"; break; case "GF": countryName = "法屬圭亞那(French Guiana,GF)"; break; case "LS": countryName = "萊索托(Lesotho,LS)"; break; case "JE": countryName = "澤西島(Jersey(Channel Islands),JE)"; break; case "DM": countryName = "多米尼加(Dominica,DM)"; break; case "ET": countryName = "埃塞俄比亞(Ethiopia,ET)"; break; case "BZ": countryName = "伯利茲(Belize,BZ)"; break; case "GG": countryName = "根西島(Guernsey(Channel Islands),GG)"; break; case "JM": countryName = "牙買加(Jamaica,JM)"; break; case "NB": countryName = "北愛爾蘭(Northern Ireland(United Kingdom),NB)"; break; case "CL": countryName = "智利(Chile,CL)"; break; case "SD": countryName = "蘇丹(Sudan,SD)"; break; case "CI": countryName = "科特迪瓦(象牙海岸)(ivory coast,CI)"; break; case "AN": countryName = "荷屬安的列斯羣島(Netherlands antilles,AN)"; break; case "CC": countryName = "科科斯羣島(Cocos(Keeling) Islands,CC)"; break; case "CU": countryName = "古巴(Cuba,CU)"; break; case "MC": countryName = "摩納哥(Monaco,MC)"; break; case "VC": countryName = "聖文森特島(St. Vincent & the Grenadines,VC)"; break; case "HK": countryName = "香港(HongKong,HK)"; break; default: countryName = countryCode; break; } return countryName; } /** * 根據國家二字碼獲取國家中文名 * * @param countryCode * @return * @author Henry(fba02) * @version [版本號, 2019年1月17日] * @see [類、類#方法、類#成員] */ public static String getCountryNameCnByCountryCode(String countryCode) { String countryNameCn = null; if (StringUtils.isBlank(countryCode)) { return countryNameCn; } String countryNameCnEnCode = getCountryNameCnByCountryCode(countryCode); if (StringUtils.isBlank(countryNameCnEnCode)) { return countryNameCn; } if (countryNameCnEnCode.indexOf("(") > -1) { countryNameCn = countryNameCnEnCode.substring(0, countryNameCnEnCode.indexOf("(")); } else { countryNameCn = countryNameCnEnCode; } return countryNameCn; } /** * 獲取國家英文名 * * @param countryCode * @return * @author Henry(fba02) * @version [版本號, 2019年1月17日] * @see [類、類#方法、類#成員] */ public static String getCountryNameEnByCountryCode(String countryCode) { String countryNameEn = null; if (StringUtils.isBlank(countryCode)) { return countryNameEn; } String countryNameCnEnCode = getCountryNameCnByCountryCode(countryCode); if (StringUtils.isBlank(countryNameCnEnCode)) { return countryNameEn; } /* * 截取括號裏面的內容 */ if (countryNameCnEnCode.indexOf("(") > -1) { countryNameEn = countryNameCnEnCode.substring(countryNameCnEnCode.indexOf("(") + 1, countryNameCnEnCode.length() - 1); countryNameEn = countryNameEn.replace("," + countryCode, ""); } else { countryNameEn = countryNameCnEnCode; } return countryNameEn; } }