Merge pull request #1371 from ancienter/develop

[bugfix]修复云端录像查询时间转换错误的问题
pull/1384/head
648540858 2024-03-18 15:39:32 +08:00 committed by GitHub
commit bfafe45b26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 2 deletions

View File

@ -59,14 +59,14 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
if (!DateUtil.verification(startTime, DateUtil.formatter)) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "开始时间格式错误,正确格式为: " + DateUtil.formatter);
}
startTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime);
startTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestampMs(startTime);
}
if (endTime != null ) {
if (!DateUtil.verification(endTime, DateUtil.formatter)) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "结束时间格式错误,正确格式为: " + DateUtil.formatter);
}
endTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime);
endTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestampMs(endTime);
}
PageHelper.startPage(page, count);

View File

@ -106,6 +106,26 @@ public class DateUtil {
return formatter.format(LocalDateTime.ofInstant(instant, ZoneId.of(zoneStr)));
}
/**
* yyyy_MM_dd_HH_mm_ss
*
* @param formatTime
* @return
*/
public static long yyyy_MM_dd_HH_mm_ssToTimestampMs(String formatTime) {
TemporalAccessor temporalAccessor = formatter.parse(formatTime);
Instant instant = Instant.from(temporalAccessor);
return instant.toEpochMilli();
}
/**
* yyyy_MM_dd_HH_mm_ss
*/
public static String timestampMsTo_yyyy_MM_dd_HH_mm_ss(long timestamp) {
Instant instant = Instant.ofEpochMilli(timestamp);
return formatter.format(LocalDateTime.ofInstant(instant, ZoneId.of(zoneStr)));
}
/**
* yyyy_MM_dd
*/