[ios]NSDateFormatter 获取第几周

 

 

NSCalendar* calendar =[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; calendar.firstWeekday =2; df.calendar = calendar; date =[NSDate dateWithString:@"2012-01-01 12:00:00 +0000"];NSLog(@"%@ -> %@", date,[df stringFromDate:date]); date =[NSDate dateWithString:@"2012-01-02 12:00:00 +0000"];NSLog(@"%@ -> %@", date,[df stringFromDate:date]); 
2012-02-2411:31:27.878Test[2546:15203]2012-02-2610:20:42+0000->02Sun2012092012-02-2411:31:27.880Test[2546:15203]2012-02-2610:20:42+0000->02Sun201209

 

calendar.firstWeekday =2;每周的第一天从星期几开始算 1 星期日 2星期一

 

参考:http://stackoverflow.com/questions/9360474/nsdateformatter-week-of-year-and-first-weekday

你可能感兴趣的:(DateFormat)