Commit 00bb8d914a5a48bae84f20bf1891b7462605a0dc

Authored by leesam
1 parent debfac58

[bugfix]修复云端录像查询时间转换错误的问题

src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java
@@ -59,14 +59,14 @@ public class CloudRecordServiceImpl implements ICloudRecordService { @@ -59,14 +59,14 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
59 if (!DateUtil.verification(startTime, DateUtil.formatter)) { 59 if (!DateUtil.verification(startTime, DateUtil.formatter)) {
60 throw new ControllerException(ErrorCode.ERROR100.getCode(), "开始时间格式错误,正确格式为: " + DateUtil.formatter); 60 throw new ControllerException(ErrorCode.ERROR100.getCode(), "开始时间格式错误,正确格式为: " + DateUtil.formatter);
61 } 61 }
62 - startTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime); 62 + startTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestampMs(startTime);
63 63
64 } 64 }
65 if (endTime != null ) { 65 if (endTime != null ) {
66 if (!DateUtil.verification(endTime, DateUtil.formatter)) { 66 if (!DateUtil.verification(endTime, DateUtil.formatter)) {
67 throw new ControllerException(ErrorCode.ERROR100.getCode(), "结束时间格式错误,正确格式为: " + DateUtil.formatter); 67 throw new ControllerException(ErrorCode.ERROR100.getCode(), "结束时间格式错误,正确格式为: " + DateUtil.formatter);
68 } 68 }
69 - endTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime); 69 + endTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestampMs(endTime);
70 70
71 } 71 }
72 PageHelper.startPage(page, count); 72 PageHelper.startPage(page, count);
src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
@@ -107,6 +107,26 @@ public class DateUtil { @@ -107,6 +107,26 @@ public class DateUtil {
107 } 107 }
108 108
109 /** 109 /**
  110 + * yyyy_MM_dd_HH_mm_ss 转时间戳(毫秒)
  111 + *
  112 + * @param formatTime
  113 + * @return
  114 + */
  115 + public static long yyyy_MM_dd_HH_mm_ssToTimestampMs(String formatTime) {
  116 + TemporalAccessor temporalAccessor = formatter.parse(formatTime);
  117 + Instant instant = Instant.from(temporalAccessor);
  118 + return instant.toEpochMilli();
  119 + }
  120 +
  121 + /**
  122 + * 时间戳(毫秒) 转 yyyy_MM_dd_HH_mm_ss
  123 + */
  124 + public static String timestampMsTo_yyyy_MM_dd_HH_mm_ss(long timestamp) {
  125 + Instant instant = Instant.ofEpochMilli(timestamp);
  126 + return formatter.format(LocalDateTime.ofInstant(instant, ZoneId.of(zoneStr)));
  127 + }
  128 +
  129 + /**
110 * 时间戳 转 yyyy_MM_dd 130 * 时间戳 转 yyyy_MM_dd
111 */ 131 */
112 public static String timestampTo_yyyy_MM_dd(long timestamp) { 132 public static String timestampTo_yyyy_MM_dd(long timestamp) {