iOS-字符串转换成NSData后在转换成字符串
2016-09-23 本文已影响48人
Mn_Su
一.字符串转换成NSData
NSDateFormatter*df = [[NSDateFormatter alloc]init];//格式化
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
[df setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"] ];
NSDate*date =[[NSDate alloc]init];
date =[df dateFromString:timeStr];
二.NSData转换成字符串
NSDateFormatter* df2 = [[NSDateFormatter alloc]init];
[df2 setDateFormat:@"MM月dd日 HH:mm"];
NSString* str1 = [df2 stringFromDate:date];