注册 登录
编程论坛 J2EE论坛

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

mgh1986 发布于 2007-01-17 21:18, 657 次点击

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;
}

3 回复
#2
angeloc2007-01-17 22:09
什么意思?
#3
mgh19862007-01-17 22:13
[原创]!!!!!!!!!!!!引
就是,我用一个15位身份证例:320323850125123
当点修改为18位身份证时 第一次点修改:改成18位是正确的
刷新后再点一次 就错了
#4
angeloc2007-01-18 09:09
你改之前判断下是否已经是18位了.
实在不行你贴代码帮你看看
1