1, NSString converted into nsdate
NSString *datestr = "2013-6-3 14:58:00";
NSDateFormatter *format=[[nsdateformatter alloc] init];
[Format setdateformat:@ "Yyyy-mm-dd HH:mm:ss"];
NSDate *date=[format DATEFROMSTRING:DATESTR];
2, NSDate converted into Longlong type
Nstimeinterval time = [date timeIntervalSince1970];
Long Long dTime = [[NSNumber numberwithdouble:time] longlongvalue];
3, Longlong type converted into nsdate
Java Time/1000 is objective-c time long long
value = [number Longlongvalue]/1000;//number is nsnumber type
nsnumber * Time = [NSNumber numberwithlonglong:value];
Convert to Nstimeinterval
nstimeinterval nstimeinterval = [Time longvalue];
NSDate *date = [[NSDate alloc] initwithtimeintervalsince1970:nstimeinterval];
4, NSDate type converted into NSString
NSDate *date = [NSDate date];
NSDateFormatter *format=[[nsdateformatter alloc] init];
[Format setdateformat:@ "Yyyy-mm-dd HH:mm:ss"];
NSString *datestring = [format stringfromdate:date];