bugfix:修复紫光华智录像查询返回StartTime、EndTime为2024-02-21T11:10:36+08:00,兼容多种不同日期格式

pull/1336/head
wendy512 2024-02-29 21:10:56 +08:00
parent 5f09692198
commit 268869c6a1
1 changed files with 13 additions and 1 deletions

View File

@ -30,6 +30,11 @@ public class DateUtil {
*/
private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
/**
* iso86012024-02-21T11:10:36+08:00
*/
private static final String ISO8601_ZONE_PATTERN = "yyyy-MM-dd'T'HH:mm:ssXXX";
/**
* wvp
*/
@ -49,6 +54,7 @@ public class DateUtil {
public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
public static final DateTimeFormatter formatterZoneISO8601 = DateTimeFormatter.ofPattern(ISO8601_ZONE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
public static final DateTimeFormatter DateFormatter = DateTimeFormatter.ofPattern(date_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
public static final DateTimeFormatter urlFormatter = DateTimeFormatter.ofPattern(URL_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
@ -59,7 +65,13 @@ public class DateUtil {
}
public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) {
return formatter.format(formatterCompatibleISO8601.parse(formatTime));
// 三种日期格式都尝试,为了兼容不同厂家的日期格式
if (verification(formatTime, formatterCompatibleISO8601)) {
return formatter.format(formatterCompatibleISO8601.parse(formatTime));
} else if (verification(formatTime, formatterZoneISO8601)) {
return formatter.format(formatterZoneISO8601.parse(formatTime));
}
return formatter.format(formatterISO8601.parse(formatTime));
}
public static String urlToyyyy_MM_dd_HH_mm_ss(String formatTime) {