+(NSString*)getWeekDay:(NSString*)currentStr
{
NSDateFormatter* dateFormat = [[NSDateFormatter alloc]init];
[dateFormatsetDateFormat:@"yyyy-MM-dd"];
NSDate*date =[dateFormatdateFromString:currentStr];
NSArray*weekdays = [NSArray arrayWithObjects: [NSNull null],@"星期日",@"星期一",@"星期二",@"星期三",@"星期四",@"星期五",@"星期六",nil];
NSCalendar*calendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSTimeZone*timeZone = [[NSTimeZonealloc]initWithName:@"Asia/Shanghai"];
[calendarsetTimeZone: timeZone];
NSCalendarUnit calendarUnit =NSCalendarUnitWeekday;
NSDateComponents*theComponents = [calendarcomponents:calendarUnitfromDate:date];
return[weekdaysobjectAtIndex:theComponents.weekday];
}
网友评论