当前位置:网站首页>Judge whether the date time exceeds 31 days
Judge whether the date time exceeds 31 days
2022-07-03 06:13:00 【Muyu】
At the end of the project , It is necessary to judge whether students are overdue , exceed 31 Days are overdue , So the following method is used .
/** * Enter two times , One is the start time , The other is the end time * Compare the two , Judge whether it is more than 31 God * @param startTime * @param endTime * @return */
public boolean checkOverdue(String startTime ,String endTime){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date end = sdf.parse(endTime);
Date start = sdf.parse(startTime);
long day = 60*1000*60*24; // 1 God
if(end.getTime()-(day*31) > start.getTime()){
return true;
}else{
return false;
}
} catch (ParseException e) {
e.printStackTrace();
}
return false;
}
Count the overdue times , First, check the borrowing records ( Here is the specific implementation of business functions )
/** * according to sid Find out the student's borrowing record * Then judge the overdue according to the borrowing time and return time in the borrowing record * Overdue is divided into the following three situations * 1. Never borrowed a book , Not overdue * 2. Borrowed books but not returned * Take out the borrowing time , Then take out the current time , If not more than 31 God , Is not overdue * Take out the borrowing time , Then take out the current time , If exceeded 31 God , Then overdue * 3. Borrowed books and returned them * Calculate the borrowing time directly , If exceeded 31 God , Then overdue * @param sid * @return */
public String checkOverdueBySid(int sid){
int num=0;
// Here is to check the borrowing record first
List<Borrow> borrows = borrowMapper.queryBorrowBySid(sid);
if(borrows==null) {
return " No overdue records ";
}else{
for (Borrow borrow : borrows) {
if("".equals(borrow.getReturnTime())||borrow.getReturnTime()==null){
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String nowTime = sdf.format(date);
if(checkOverdue(borrow.getBorrowTime(),nowTime)){
num+=1;
}
}else{
if(checkOverdue(borrow.getBorrowTime(),borrow.getReturnTime())){
num+=1;
}
}
}
if(num==0){
return " No overdue records ";
}else{
return " Within the time limit "+num+" Time ";
}
}
}
边栏推荐
- The most responsible command line beautification tutorial
- Phpstudy setting items can be accessed by other computers on the LAN
- Code generator - single table query crud - generator
- Simple solution of small up main lottery in station B
- Kubernetes notes (V) configuration management
- 认识弹性盒子flex
- Oauth2.0 - Introduction and use and explanation of authorization code mode
- 代码管理工具
- 【C#/VB.NET】 将PDF转为SVG/Image, SVG/Image转PDF
- Yum is too slow to bear? That's because you didn't do it
猜你喜欢

YOLOV2学习与总结

Zhiniu stock project -- 05

arcgis创建postgre企业级数据库

Merge and migrate data from small data volume, sub database and sub table Mysql to tidb

Interesting research on mouse pointer interaction

Detailed explanation of contextclassloader

Disruptor learning notes: basic use, core concepts and principles

Maximum likelihood estimation, divergence, cross entropy

Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster

ruoyi接口权限校验
随机推荐
MySQL带二进制的库表导出导入
Oauth2.0 - explanation of simplified mode, password mode and client mode
ruoyi接口权限校验
YOLOV3学习笔记
BeanDefinitionRegistryPostProcessor
多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)
Svn branch management
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
SQL实现将多行记录合并成一行
Project summary --04
pytorch DataLoader实现miniBatch(未完成)
Kubesphere - Multi tenant management
Mysql database table export and import with binary
Kubernetes notes (VI) kubernetes storage
Analysis of Clickhouse mergetree principle
In depth analysis of kubernetes controller runtime
【C#/VB.NET】 将PDF转为SVG/Image, SVG/Image转PDF
. Net program configuration file operation (INI, CFG, config)
有意思的鼠标指针交互探究
Mysql database