Commit 00bb8d914a5a48bae84f20bf1891b7462605a0dc
1 parent
debfac58
[bugfix]修复云端录像查询时间转换错误的问题
Showing
2 changed files
with
22 additions
and
2 deletions
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) { | ... | ... |