| | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); |
| | | for (String file : files) { |
| | | String fileName = ComHelper.getNameWithExt(file); |
| | | // 解析为 LocalDateTime(默认基于系统时区,可能需指定时区) |
| | | LocalDateTime dateTime = LocalDateTime.parse(fileName, formatter); |
| | | // 转换为 UTC 时间戳(推荐,避免时区歧义) |
| | | Instant utcInstant = dateTime.atZone(ZoneId.of("UTC")).toInstant(); |
| | | long timestamp = utcInstant.toEpochMilli(); |
| | | Instant instant = dateTime.atZone(ZoneId.systemDefault()).toInstant(); |
| | | long timestamp = instant.toEpochMilli(); |
| | | layer.getWaters().getData().add(timestamp); |
| | | } |
| | | layer.getDuration().setStart(layer.getWaters().getData().get(0)); |