diff --git a/src/main/java/com/biutag/supervision/service/ModelClueService.java b/src/main/java/com/biutag/supervision/service/ModelClueService.java index 7afaa57..e38efd6 100644 --- a/src/main/java/com/biutag/supervision/service/ModelClueService.java +++ b/src/main/java/com/biutag/supervision/service/ModelClueService.java @@ -1265,43 +1265,23 @@ public class ModelClueService extends ServiceImpl { String time = null; try { time = String.valueOf(param); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - Date parse = sdf.parse(time); - Instant instant = parse.toInstant(); - ZoneId zoneId = ZoneId.systemDefault(); - LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分"); - return formatter.format(localDateTime); + LocalDateTime localDateTime = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")); + return localDateTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分")); } catch (Exception e) { try { time = String.valueOf(param); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); - Date parse = sdf.parse(time); - Instant instant = parse.toInstant(); - ZoneId zoneId = ZoneId.systemDefault(); - LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分"); - return formatter.format(localDateTime); + LocalDateTime localDateTime = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S")); + return localDateTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分")); } catch (Exception ex) { try { time = String.valueOf(param); - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); - Date parse = sdf.parse(time); - Instant instant = parse.toInstant(); - ZoneId zoneId = ZoneId.systemDefault(); - LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分"); - return formatter.format(localDateTime); + LocalDateTime localDateTime = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); + return localDateTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分")); } catch (Exception exx) { try { time = String.valueOf(param); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date parse = sdf.parse(time); - Instant instant = parse.toInstant(); - ZoneId zoneId = ZoneId.systemDefault(); - LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分"); - return formatter.format(localDateTime); + LocalDateTime localDateTime = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + return localDateTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分")); } catch (Exception exxx) { log.info("日期转换异常{}", time, ex); }