Here you can find the source of getBirthDay(String idCard)
public static Date getBirthDay(String idCard) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static final String DateFormatPattern = "yyyyMMdd"; public static Date getBirthDay(String idCard) throws ParseException { String birthDay;//from w w w .j a v a 2s . co m if (idCard.length() == 15) { birthDay = "19" + idCard.substring(6, 12); } else { birthDay = idCard.substring(6, 14); } SimpleDateFormat dateFormat = new SimpleDateFormat(DateFormatPattern, Locale.ENGLISH); return dateFormat.parse(birthDay); } }