根据身份证前2位判断属于哪个省
Posted 山高似水深
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了根据身份证前2位判断属于哪个省相关的知识,希望对你有一定的参考价值。
package com.sycx.domain; public class ProByIDcard { public static String GetPro(String word){ String pro = "错误身份证号"; if(word.equals("11")){ pro = "北京市"; }else if(word.equals("12")){ pro = "天津市"; }else if(word.equals("13")){ pro = "河北省"; }else if(word.equals("14")){ pro = "山西省"; }else if(word.equals("15")){ pro = "内蒙古自治区"; }else if(word.equals("21")){ pro = "辽宁省"; }else if(word.equals("22")){ pro = "吉林省"; }else if(word.equals("23")){ pro = "黑龙江省"; }else if(word.equals("31")){ pro = "上海市"; }else if(word.equals("32")){ pro = "江苏省"; }else if(word.equals("33")){ pro = "浙江省"; }else if(word.equals("34")){ pro = "安徽省"; }else if(word.equals("35")){ pro = "福建省"; }else if(word.equals("36")){ pro = "江西省"; }else if(word.equals("37")){ pro = "山东省"; }else if(word.equals("41")){ pro = "河南省"; }else if(word.equals("42")){ pro = "湖北省"; }else if(word.equals("43")){ pro = "湖南省"; }else if(word.equals("44")){ pro = "广东省"; }else if(word.equals("45")){ pro = "广西壮族自治区"; }else if(word.equals("46")){ pro = "海南省"; }else if(word.equals("50")){ pro = "重庆市"; }else if(word.equals("51")){ pro = "四川省"; }else if(word.equals("52")){ pro = "贵州省"; }else if(word.equals("53")){ pro = "云南省"; }else if(word.equals("54")){ pro = "西藏自治区"; }else if(word.equals("61")){ pro = "陕西省"; }else if(word.equals("62")){ pro = "甘肃省"; }else if(word.equals("63")){ pro = "青海省"; }else if(word.equals("64")){ pro = "宁夏回族自治区"; }else if(word.equals("65")){ pro = "新疆维吾尔自治区"; }else if(word.equals("71")){ pro = "台湾省 "; }else if(word.equals("81")){ pro = "香港特别行政区"; }else if(word.equals("66")){ pro = "新疆兵团"; }else if(word.equals("91")){ pro = "澳门特别行政区"; } return pro; } }
以上是关于根据身份证前2位判断属于哪个省的主要内容,如果未能解决你的问题,请参考以下文章
18位身份证的编码规则是: 前12位数字表示:所在省(直辖市自治区)的代码 第34位数字表示:所在地级市(自治州)的代码 第56位数字表示:所在区(县自治县县级市)的代码; 第7—14位数