⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 identitycard.java

📁 /** * 去除字符串s左边的半角空格 * @param s 字符串 * @return 去除左边半角空格后的字符串 */
💻 JAVA
字号:
package com.totyuedu.c69.a20080905;

import java.text.SimpleDateFormat;
import java.util.Date;

public class IdentityCard {

    private String id;

    private Date birthday;

    public IdentityCard(String id) throws Exception {
        this.id = id;
        birthday = getBirthday(id);
    }

    private Date getBirthday(String id) throws Exception {
        if (id == null || id.length() != 18) {
            throw new Exception("非法身份证号码");
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        return sdf.parse(id.substring(6, 14));
    }

    public Date getBirthday() {
        return birthday;
    }

    public String getId() {
        return id;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -