添加了TimeUtils工具类

master
ArgonarioD 2022-07-03 19:59:07 +08:00
parent d98b6d3928
commit 6eb7c68a18
2 changed files with 39 additions and 0 deletions

View File

@ -18,6 +18,7 @@ public class Project {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Integer projectId; private Integer projectId;
private String projectName; private String projectName;
//TODO: 时间线顺序判断
private LocalDate projectStartTime; private LocalDate projectStartTime;
private LocalDate projectOnlineTime; private LocalDate projectOnlineTime;
private LocalDate projectFirstTestTime; private LocalDate projectFirstTestTime;

View File

@ -0,0 +1,38 @@
package cn.edu.hfut.rmdjzz.projectmanagement.utils;
import java.time.Instant;
import java.time.temporal.TemporalAccessor;
/**
* @author
* @since 2022/7/2 9:13
*/
public class TimeUtils {
/**
* 线null
*/
public static boolean validateTimeLine(TemporalAccessor... temporalAccessors) {
int first;
for (first = 0; first < temporalAccessors.length; first++) {
if (temporalAccessors[first] != null) {
break;
}
}
if (first >= temporalAccessors.length - 1) {
return true;
}
Instant last = Instant.from(temporalAccessors[first]);
Instant current;
for (int i = first + 1; i < temporalAccessors.length; i++) {
if (temporalAccessors[i] == null) {
continue;
}
current = Instant.from(temporalAccessors[i]);
if (last.isAfter(current)) {
return false;
}
last = current;
}
return true;
}
}