当前位置:网站首页>There is no crossover in the time period within 24 hours
There is no crossover in the time period within 24 hours
2022-07-28 05:28:00 【MusicCodeM】
Tips : When the article is finished , Directories can be generated automatically , How to generate it, please refer to the help document on the right
List of articles
Code
2:00 - 4:00 6:00- 8:00
The idea is to turn these into dates lcoalDateTime Compare , This is the idea , The code is not tested .
/** * Determine whether Whether the time period repeats , Overlapped return false , No overlapping returns true * @Param startTime Enter the start time * @Param endTime End time of output * @Param isStartTime Start time of comparison * @Param isEndTime End time of comparison * */
public static boolean isOverlap(String startTime, String endTime , String isStartTime, String isEndTime ){
// add prefix yyyy-MM-dd
String frontTime1 = "1970-01-01";
String frontTime2 = "1970-01-02";
startTime = frontTime1 +" "+startTime; // 197-01-01 23:00
// Description is a yes stay 00 Before the point ,, In a 00 After the point such as 23:00 - 3:00
if(startTime.compareTo(endTime) > 0 ){
endTime = frontTime2 + " " + endTime;
}else{
endTime = frontTime1 + " " + endTime;
}
isStartTime = frontTime1 +" "+isStartTime;
if(isStartTime.compareTo(isEndTime) > 0 ){
isEndTime = frontTime2 + " " + isEndTime;
}else{
isEndTime = frontTime1 + " " + isEndTime;
}
// String rotation localdateTime
LocalDateTime localStartTime= LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime localEndTime= LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime localIsStartTime= LocalDateTime.parse(isStartTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime localIsEndTime= LocalDateTime.parse(isEndTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// No, 00 The difference between the 3:00 -8:00 4:00-6:00 3:00 -8:00 2:00-6:00 2:00-9:00 8:00 -5:00
// start < end isStart< end
if( ( localEndTime.isEqual(localIsStartTime) || localEndTime.isBefore(localIsStartTime) )
&& ( localStartTime.plusDays(1).isAfter(localIsEndTime) ) // Make sure not to exceed 24 Hours
){
// situation 1 : 3:00 -8:00 8:00-9:00
return true;
}else if( ( localIsEndTime.isEqual(localStartTime) || localIsEndTime.isBefore(localStartTime) )
&& ( localIsStartTime.plusDays(1).isAfter(localEndTime) )
){
//9:00 -11:00 8:00-9:00
return true;
}else{
return false;
}
}
边栏推荐
- I've been in an outsourcing company for two years, and I feel like I'm going to die
- VMware Workstation 与 Device/Credential Guard 不兼容。禁用 Device/Credential Guard
- C language classic 100 question exercise (1~21)
- Response<T>类
- 在ruoyi生成的对应数据库的代码 之后我该怎么做才能做出下边图片的样子
- Antd setfieldsvalue warning problem cannot use 'setfieldsvalue' until you use 'getfielddecorator' or
- Share several methods of managing flag bits in C program
- [computer level 3 information security] overview of information security assurance
- Jsonp single sign on permission verification
- Internal implementation principle of yymodel
猜你喜欢

restFul接口使用个人总结

这种动态规划你见过吗——状态机动态规划之股票问题(中)

【内功心法】——函数栈帧的创建和销毁(C实现)

MySQL basic query
Printf function of input and output function in C language

Professor dongjunyu made a report on the academic activities of "Tongxin sticks to the study of war and epidemic"

IDEA使用dev-tool实现热部署

Offline loading of wkwebview and problems encountered

Long和Integer如何进行比较,为什么报错

First acquaintance with C language (2)
随机推荐
导出excel,生成多个sheet页,并命名
Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
How to analyze fans' interests?
7.<tag-字符串和API的取舍>补充: 剑指 Offer 05. 替换空格
2022 summer practice (PowerDesigner tutorial learning record) (first week)
多模块打包:程序包:xxx不存在
About MySQL group_ What concat has to say
HashSet add
CPU and memory usage are too high. How to modify RTSP round robin detection parameters to reduce server consumption?
Redis 之布隆过滤器
IDEA配置 service(Run Dashboard) 服务,多模块同时启动
多线程进阶:synchronized底层原理,锁优化、锁升级的过程
21 day SQL punch in summary
分享几种管理C程序中标志位的方法
block yandex bot
[slam] lvi-sam analysis - Overview
Edge calculation kubeedge+edgemash
C language: some self realization of string functions
【ARIXV2204】Neighborhood attention transformer
【单例模式】懒汉模式的线程安全问题