创建一个时间格式化对象
NSDateFormatter *datef = [[NSDateFormatter alloc] init];
设定时间的格式
[datef setDateFormat:@"yyyy-MM-dd"];
将字符串转换为时间对象
NSDate *tempDate = [datef dateFromString:str];
获取代表公历的Calendar对象
NSCalendar *calenar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
定义一个时间段的旗标,指定将会获取指定的年,月,日,时,分,秒的信息
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekdayCalendarUnit;
获取不同时间字段信息
NSDateComponents *dateComp = [calenar components:unitFlags fromDate:date];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NSString *cString = [[color stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~