ここから以前の例を参照しました。しかし、null 値にはまだ問題があります。
文字列値:==> strDate = "09-05-2012 00:00:00"
:==> 2012 年 5 月 9 日として出力したい
私のコード:
NSString *strDateFormat;//[strDate substringWithRange:NSMakeRange(0, 10)];
strDateFormat = [NSString stringWithFormat:@"%@", strDate];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
NSDate *disDate = [df dateFromString:strDateFormat];
[df setDateFormat:@"MMM dd, yyyy"];
strDateFormat = [df stringFromDate:disDate];
lblDate.text = [NSString stringWithFormat:@"%@", strDateFormat];
[df release];
(null) 値を返します。disDate には (null) 値があるためです。
disDate が nil に設定されているのはなぜですか? 解決策はありますか..?