Commit bfafe45b26e278d35a9f50e20178164be9c85e22

Authored by 648540858
Committed by GitHub
2 parents f4e41659 00bb8d91

Merge pull request #1371 from ancienter/develop

[bugfix]修复云端录像查询时间转换错误的问题
src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java
... ... @@ -59,14 +59,14 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
59 59 if (!DateUtil.verification(startTime, DateUtil.formatter)) {
60 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 65 if (endTime != null ) {
66 66 if (!DateUtil.verification(endTime, DateUtil.formatter)) {
67 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 72 PageHelper.startPage(page, count);
... ...
src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
... ... @@ -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 130 * 时间戳 转 yyyy_MM_dd
111 131 */
112 132 public static String timestampTo_yyyy_MM_dd(long timestamp) {
... ...