Java Day of getBirthDay(String idCard)

Here you can find the source of getBirthDay(String idCard)

Description

get Birth Day

License

Apache License

Declaration

public static Date getBirthDay(String idCard) throws ParseException 

Method Source Code

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

Related

  1. getBeforeOrAfterDay(Date date, String format, Integer days)
  2. getBeginEndTimeOfDay(Date day)
  3. getBeginOfDay(Date date)
  4. getBeginTimeOfDay(Date date, int offset)
  5. getBirthday(String age)
  6. getBirthDayDateFormat()
  7. getBirthdayFormatStr(Date date)
  8. getBookInfoDate(int days)
  9. getCalendarByDay(String dayStr)