当前位置: 代码迷 >> Java Web开发 >> [讨论]15位身份转18位,怎么一个号连续点2次就变那??
  详细解决方案

[讨论]15位身份转18位,怎么一个号连续点2次就变那??

热度:116   发布时间:2007-01-17 21:18:33.0
[讨论]15位身份转18位,怎么一个号连续点2次就变那??

String[] wv={"1","0","X","9","8","7","6","5","4","3","2"};
int[] wc={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1};
String oldid=null;
String newid=null;
String asd=null;
String bsd=null;
String csd=null;
String dsd=null;
int sdf;
int mgh1;
int mgh2;
int qwe;
String mgh3;

public int getMgh1() {
return mgh1;
}

public int getMgh2() {
return mgh2;
}

public String getNewid() {
if(oldid.length()==15)
{
csd=(oldid.substring(0,6))+asd+oldid.substring(6);
for(int i=0;i<csd.length();i++)
{
mgh1=Integer.parseInt(csd.substring(i,i+1))*wc[i];
mgh2+=mgh1;
}

sdf=mgh2%11;

newid=csd+wv[sdf];

}
return newid;
}

public String getOldid() {
return oldid;
}

public String getAsd() {
return asd;
}

public String getBsd() {
return bsd;
}

public String getCsd() {
return csd;
}

public String getDsd() {
return dsd;
}

public int[] getWc() {
return wc;
}

public String[] getWv() {
return wv;
}

public String getMgh3() {
qwe=sdf%2;
if (qwe == 0) {
mgh3 ="女";
}
else
{
mgh3="男";
}
return mgh3;
}

搜索更多相关主题的帖子: 身份  

----------------解决方案--------------------------------------------------------
什么意思?
----------------解决方案--------------------------------------------------------
[原创]!!!!!!!!!!!!引
就是,我用一个15位身份证例:320323850125123
当点修改为18位身份证时 第一次点修改:改成18位是正确的
刷新后再点一次 就错了
----------------解决方案--------------------------------------------------------
你改之前判断下是否已经是18位了.
实在不行你贴代码帮你看看
----------------解决方案--------------------------------------------------------
  相关解决方案