我知道对此有很多问题,但似乎没有一个答案对我有用。这是我的代码(iOS SDK 6.0)
NSDateFormatter *df = [NSDateFormatter alloc];
[df setDateFormat:@"yyyy-MM-dd"];
[df setFormatterBehavior:NSDateFormatterBehavior10_4];
[df setTimeZone:[NSTimeZone defaultTimeZone]];
[df setLocale:[NSLocale currentLocale];
NSDate *TERMIN = [NSDate alloc];
TERMIN = [df dateFromString:T]; //'T' is date in string NSLog(...,T) is 2002-05-05
当我TERMIN
通过NSLog
输出输出时(null)