Pass the ID number to return the birthday string

Source: Internet
Author: User


- (void) viewdidload{[Super Viewdidload]; //Do any additional setup after loading the view.NSString*birthday=[self Birthdaystrfromidentitycard:@"134825194401014241"]; NSLog (@"--birthday-%@", BirthDay); }//Pass ID to return birthday string-(NSString *) Birthdaystrfromidentitycard: (NSString *) numberstr{nsmutablestring*result = [nsmutablestring stringwithcapacity:0]; NSString*year =Nil; NSString*month =Nil; BOOL Isallnumber=YES; NSString*day =Nil; if([Numberstr length]< -)        returnresult; //* * Interception of the first 14 digitsNSString *fontnumer = [Numberstr substringwithrange:nsmakerange (0, -)]; //* * The first 14 digits of the test are all numbers;    Const Char*str =[Fontnumer utf8string]; Const Char*p =str;  while(*p!=' /') {        if(! (*p>='0'&&*p<='9')) Isallnumber=NO; P++; }        if(!isallnumber)returnresult; year= [Numberstr Substringwithrange:nsmakerange (6,4)]; Month= [Numberstr Substringwithrange:nsmakerange (Ten,2)]; Day= [Numberstr Substringwithrange:nsmakerange ( A,2)];    [Result Appendstring:year]; [Result appendString:@"-"];    [Result Appendstring:month]; [Result appendString:@"-"];    [Result Appendstring:day]; returnresult; }


2014-12-02 11:51:24.089 Pass the ID number to return the birthday string [7594:60b]--birthday-1944-01-01

Pass the ID number to return the birthday string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.