使用 java.time.Instant代替 java.util.Date
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
public class CatalogData {
|
||||
private int sn; // 命令序列号
|
||||
private int total;
|
||||
private List<DeviceChannel> channelList;
|
||||
private Date lastTime;
|
||||
private Instant lastTime;
|
||||
private Device device;
|
||||
private String errorMsg;
|
||||
|
||||
@@ -41,11 +41,11 @@ public class CatalogData {
|
||||
this.channelList = channelList;
|
||||
}
|
||||
|
||||
public Date getLastTime() {
|
||||
public Instant getLastTime() {
|
||||
return lastTime;
|
||||
}
|
||||
|
||||
public void setLastTime(Date lastTime) {
|
||||
public void setLastTime(Instant lastTime) {
|
||||
this.lastTime = lastTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -20,7 +20,7 @@ public class RecordInfo {
|
||||
|
||||
private int sumNum;
|
||||
|
||||
private Date lastTime;
|
||||
private Instant lastTime;
|
||||
|
||||
private List<RecordItem> recordList;
|
||||
|
||||
@@ -72,11 +72,11 @@ public class RecordInfo {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public Date getLastTime() {
|
||||
public Instant getLastTime() {
|
||||
return lastTime;
|
||||
}
|
||||
|
||||
public void setLastTime(Date lastTime) {
|
||||
public void setLastTime(Instant lastTime) {
|
||||
this.lastTime = lastTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
|
||||
/**
|
||||
* @description:设备录像bean
|
||||
@@ -116,17 +117,17 @@ public class RecordItem implements Comparable<RecordItem>{
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull RecordItem recordItem) {
|
||||
try {
|
||||
Date startTime_now = DateUtil.format.parse(startTime);
|
||||
Date startTime_param = DateUtil.format.parse(recordItem.getStartTime());
|
||||
if (startTime_param.compareTo(startTime_now) > 0) {
|
||||
return -1;
|
||||
}else {
|
||||
return 1;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
TemporalAccessor startTimeNow = DateUtil.formatter.parse(startTime);
|
||||
TemporalAccessor startTimeParam = DateUtil.formatter.parse(recordItem.getStartTime());
|
||||
Instant startTimeParamInstant = Instant.from(startTimeParam);
|
||||
Instant startTimeNowInstant = Instant.from(startTimeNow);
|
||||
if (startTimeNowInstant.equals(startTimeParamInstant)) {
|
||||
return 0;
|
||||
}else if (Instant.from(startTimeParam).isAfter(Instant.from(startTimeNow)) ) {
|
||||
return -1;
|
||||
}else {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user