截取 与效率,

////生日数字的 转化 19900615

-(NSDate *)dateFromBirthDay:(NSString *)birthdayString

{

  

    NSDateFormatter *formatter = [[NSDateFormatteralloc]init];

    [formatter setDateFormat:@"yyyyMMdd"];

    return [formatter dateFromString:birthdayString];

//    NSRange yearRange = NSMakeRange(0, 4);

//    int mYear = [[birthdayString substringWithRange:yearRange] intValue];

//

//    NSRange monthRange = NSMakeRange(4, 2);

//    int mMonth = [[birthdayString substringWithRange:monthRange] intValue];

//

//    NSRange dayRange = NSMakeRange(6, 2);

//    int mDay = [[birthdayString substringWithRange:dayRange]intValue];

//    NSDateComponents *comp = [[NSDateComponents alloc]init];

//    [comp setMonth:mMonth];

//    [comp setDay:mDay];

//    [comp setYear:mYear];

//    NSCalendar *myCal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

//    NSDate *myDate = [myCal dateFromComponents:comp];

//    return myDate;

 

}

posted @ 2013-09-01 16:14  路在脚下,  阅读(158)  评论(0编辑  收藏  举报