Possible Duplicate:
iOS: How to get a proper Month name from a number?
如何从月份编号中获取月份名称?
我有像02这样的月份编号,但希望月份为字符串,在本例中为二月。
最佳答案
类似这样的事情:
int monthNumber = 11;
NSString * dateString = [NSString stringWithFormat: @"%d", monthNumber];
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM"];
NSDate* myDate = [dateFormatter dateFromString:dateString];
[dateFormatter release];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMMM"];
NSString *stringFromDate = [formatter stringFromDate:myDate];
[formatter release];
NSLog(@"%@", stringFromDate);
关于iphone 如何从月份编号获取月份名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4887712/