Java判断两个时间段是否有交集
来源:互联网 发布:sybase数据网站 编辑:程序博客网 时间:2024/04/27 21:47
public static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private static boolean isOverlap(String startdate1, String enddate1,String startdate2, String enddate2) { Date leftStartDate = null; Date leftEndDate = null; Date rightStartDate = null; Date rightEndDate = null; try { leftStartDate = format.parse(startdate1); leftEndDate = format.parse(enddate1); rightStartDate = format.parse(startdate2); rightEndDate = format.parse(enddate2); } catch (ParseException e) { return false; } return ((leftStartDate.getTime() >= rightStartDate.getTime()) && leftStartDate.getTime() < rightEndDate.getTime()) || ((leftStartDate.getTime() > rightStartDate.getTime()) && leftStartDate.getTime() <= rightEndDate.getTime()) || ((rightStartDate.getTime() >= leftStartDate.getTime()) && rightStartDate.getTime() < leftEndDate.getTime()) || ((rightStartDate.getTime() > leftStartDate.getTime()) && rightStartDate.getTime() <= leftEndDate.getTime()); }
true:有交集
false:无交集
0 0
- Java判断两个时间段是否有交集
- 判断两个时间段是否有交集
- 判断两个时间段是否有交集
- SQL判断两个时间段是否有交集
- php 判断两个时间段 是否有交集
- 判断两个时间段,是否交集 java
- sql语句判断两个时间段是否有交集
- 【技术支持】判断两个时间段是否有交集的伪代码
- sql语句判断两个时间段是否有交集
- sql语句判断两个时间段是否有交集
- sql语句判断两个时间段是否有交集
- 判断2个时间段是否有交集
- 在ORalce 中,怎么判断两个时间段之间是否有交集, 编写的一个函数.
- SQL Server 查询两个时间段是否有交集
- Android 比较两个时间段是否有交集或重复
- 查询两个时间段是否有交集的情况
- mysql 查询两个时间段是否有交集的情况
- 判断两个矩形是否有交集
- 集合心得
- 1053. Path of Equal Weight (30)
- Active Defense Harbinger Distribution
- GCJ 2009 Round2 A (Crazy Rows)
- 开发线程安全的Servlet
- Java判断两个时间段是否有交集
- HTML5 Canvas绘图API
- PAT 1083. List Grades (25)
- QQ空间g_tk算法的JS脚本的获取和分析
- Clothes
- 代沐研:非农战幕终拉开,金银油空头强袭
- 忆昔悟今
- 应用程序的 DIY__(给程序加上新功能)
- 9.3 - 抗战胜利日