星空网 > 软件开发 > 操作系统

【代码笔记】两个时间字符串的比较

一,效果图。

【代码笔记】两个时间字符串的比较images/loading.gif' data-original="http://images2015.cnblogs.com/blog/337518/201510/337518-20151019145201833-1919179618.jpg" width="218" height="400" />

二,代码。

【代码笔记】两个时间字符串的比较
- (void)viewDidLoad{  [super viewDidLoad];  // Do any additional setup after loading the view.    [self initTimerCompare];  }#pragma -mark -functions//比较时间-(void)initTimerCompare{    NSString *starTimer=@"2014-08-29";  NSString *finishTimer=@"2014-09-30";    BOOL result = [starTimer compare:finishTimer] == NSOrderedSame;  NSLog(@"result:%d",result);  if (result==1) {    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"开始时间和结束时间相等" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil];    [alert show];    return;  }    BOOL result1 = [starTimer compare:finishTimer]==NSOrderedDescending;  NSLog(@"result1:%d",result1);  if (result1==1) {    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"开始时间晚于结束时间" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil];    [alert show];    return;  }    BOOL result2 = [starTimer compare:finishTimer]==NSOrderedAscending;  NSLog(@"result2:%d",result1);  if (result2==1) {    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"开始时间早于结束时间" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil];    [alert show];    return;  }}
【代码笔记】两个时间字符串的比较

 

 


 

原标题:【代码笔记】两个时间字符串的比较

关键词:时间

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

临沂跨境电商:https://www.goluckyvip.com/tag/596.html
FBA物流计划:https://www.goluckyvip.com/tag/5960.html
德国包装法证书:https://www.goluckyvip.com/tag/59603.html
德国包装法上传:https://www.goluckyvip.com/tag/59604.html
德国包装法在哪里看:https://www.goluckyvip.com/tag/59605.html
德国包装法印刷:https://www.goluckyvip.com/tag/59606.html
武陵山大裂谷周围景点 武陵山大裂谷周围景点图片:https://www.vstour.cn/a/411233.html
南美旅游报价(探索南美洲的旅行费用):https://www.vstour.cn/a/411234.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流