嗨,我正在尝试格式化从服务器获取的日期。我试过这样
NSString *dateStr =@"2012-5-21";
// Convert string to date object
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-mm-dd"];
NSDate *date = [dateFormat dateFromString:dateStr];
// Convert date object to desired output format
[dateFormat setDateFormat:@"dd MMM yyyy"];
dateStr = [dateFormat stringFromDate:date];
finalDate.text=dateStr;
[dateFormat release];
但代替21 May 2012
. 我正进入(状态21 Jan 2012