Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

// If the status is 1, the time will be recorded and stored in the database, MySQL database
if (status == 1) {
 long start = System.currentTimeMillis();
} else if (status != 1) {
 // 具体的实现逻辑
 // If the status is 0, the recording time is stopped and the start time and stop time are intercepted into the database
 // long end = System.currentTimeMillis();
 // 具体的实现逻辑
}
// 数据保存到数据库中
data.setStVal(Integer.valueOf(status));
data.setUpdateTime(new Date());
iec61850DataService.updateById(data);

问题描述

这个需求是需要对一个程序进行的状态进行判定,如果状态为1,就进行计时,格式为:记录时间 2020-11-09 17:25:21,如果状态为0,则停止计时,请各位大佬帮忙想想办法,谢谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

if (status == 1) {
 data.setStart(System.currentTimeMillis());
} else {
 data.setEnd(System.currentTimeMillis());
}
updateById(data);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...