/**
* @创建时间:2007-5-10 下午04:26:26
* @修改者:lics
* @修改时间:2007-5-10 下午04:26:26
* @说明:根据身份证号生成出生日期
*/
package nc.ui.ps.pub;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDate;
import nc.vo.uap.busibean.exception.BusiBeanException;
/**
* @创建时间:2007-5-10 下午04:26:26
* @修改者:lics
* @修改时间:2007-5-10 下午04:26:26
* @说明:根据身份证号生成出生日期
*/
public class GainBirthday {
/**
* @创建时间:2007-5-10 下午04:26:27
* @修改者:lics
* @修改时间:2007-5-10 下午04:26:27
* 方法说明:构造方法
*
*/
public GainBirthday() {
// lcs 自动生成构造函数存根
}
/**
*
* @方法说明:根据身份证号生成出生日期
* @创建时间:2007-5-10 下午05:05:20
* @修改者:lics
* @修改时间:2007-5-10 下午05:05:20
* @param cardID 15位或18位的身份证号
* @return 出生日期
* @throws BusinessException
*
*/
public static UFDate getBirthday(String cardID) throws BusinessException{
UFDate returnDate=null;
StringBuffer tempStr=null;
if(cardID!=null&&cardID.trim().length()>0){
if(cardID.trim().length()==15){
tempStr=new StringBuffer(cardID.substring(6, 12));
tempStr.insert(4, '-');
tempStr.insert(2, '-');
tempStr.insert(0, "19");
}else if(cardID.trim().length()==18){
tempStr=new StringBuffer(cardID.substring(6, 14));
tempStr.insert(6, '-');
tempStr.insert(4, '-');
}
}
if(tempStr!=null&&tempStr.toString().trim().length()>0){
try{
returnDate=new UFDate(tempStr.toString());
}catch(Exception e){
throw new BusinessException("输入的身份证错误,不能转换为相应的出生日期");
}
}
return returnDate;
}
}