我試圖把其格式爲「11年2月22日」一個NSString的日期並將其轉換爲這種格式:2011-02-22NSDateFormatter和YYYY-MM-DD
這是我的代碼:
NSDate *dateTemp = [[NSDate alloc] init];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
dateTemp = [dateFormat dateFromString:newInvoice.date];
newInvoice.date = [dateFormat stringFromDate:dateTemp];
newInvoice.date
以等於「2/22/11」的NSString開始。 dateTemp
結束NIL。 newInvoice.date
也以NIL結尾。
我不能爲我的生活找出原因。
即,需要2個格式化程序:一個用於輸入,一個用於輸出。 – Wevah 2011-02-23 05:51:57