//去掉服务器返回结果文本中的<null>
+ (NSString *)replaceNull:(NSString *)source
{
NSString *result = [NSString stringWithFormat:@"%@", source];
if (result != nil && (NSNull *)result != [NSNull null]) {
if ([result isEqualToString:@"<null>"]) {
return @"";
} else if ([result isEqualToString:@"(null)"]) {
return @"";
}else if ([result isEqualToString:@"null"]){
return @"";
}else {
return result;
}
} else {
return @"";
}
}
//判断服务器返回List类型
+ (BOOL)arrayIfNull:(id)source
{
if ([source isKindOfClass:[NSArray class]]) {
return YES;
}else{
return NO;
}
}
//判断字符串是否为纯数字
+ (BOOL)isPureInt:(NSString*)string
{
NSScanner* scan = [NSScanner scannerWithString:string];
int val;
return[scan scanInt:&val] && [scan isAtEnd];
}
//时间转换 yyyy年MM月dd日 HH:mm:ss
+ (NSString *)getTimeWithDate1:(NSNumber *)numberTime{
CGFloat secondTime = [numberTime floatValue]/1000;
NSDate *time = [NSDate dateWithTimeIntervalSince1970:secondTime];
NSDateFormatter *timerFormatter = [[NSDateFormatter alloc] init];
[timerFormatter setDateFormat:@"yyyy年MM月dd日 HH:mm:ss"];
NSString *timeString = [timerFormatter stringFromDate:time];
return timeString;
}
//时间转换 yyyy年MM月dd日
+ (NSString *)getTimeWithDate:(NSNumber *)numberTime{
CGFloat secondTime = [numberTime floatValue]/1000;
NSDate *time = [NSDate dateWithTimeIntervalSince1970:secondTime];
NSDateFormatter *timerFormatter = [[NSDateFormatter alloc] init];
[timerFormatter setDateFormat:@"yyyy年MM月dd日"];
NSString *timeString = [timerFormatter stringFromDate:time];
return timeString;
}