自己在程序中需要计算重合的时间段,但是首先需要判断是否重合。后来,发现下面的总结特别精辟。
判断两个时间段是否重叠,如:
startdate1 — enddate1
startdate2 — enddate2
两个时间的重叠分4种情况,若你一一列出这四种情况来判断是否重叠那就弱爆了,最简单的方法:
startdate1 <=enddate2 and enddate1>=startdate2