如何將@「20090302」轉換爲@「2009/03/02」或@「02/03/2009」?重新格式化表示日期的NSString
我找到了解決辦法,這是更新
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"YYYYMMDD"];
NSDate *date = [formatter dateFromString:yourinoutstring];
[formatter setDateFormat:@"DD/MM/YYYY"];
NSString *outDate = [formatter stringFromDate:date];
已回答重複:http://stackoverflow.com/questions/1353081/nsstring-to-nsdate – Blender 2011-03-20 13:51:05
我需要的輸出也是nsstring – Ali 2011-03-20 13:54:07
然後轉換'NSString - > N SDate - > NSString'。你在用什麼日期? – Blender 2011-03-20 13:54:57