| | |
| | | import java.math.BigDecimal; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.OffsetDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | private BigDecimal ratedPower; |
| | | @Excel(name = "*是否峰谷分时", width = 20, readConverterExp = "0=否,1=是") |
| | | private Integer periodFee; |
| | | @Excel(name = "*正式投运时间", width = 22, prompt = "格式:yyyy-MM-dd") |
| | | @Excel(name = "*正式投运时间", width = 22, prompt = "格式:yyyy-MM-dd HH:mm:ss") |
| | | private String officialRunTime; |
| | | @Excel(name = "充换电站方位", width = 24, readConverterExp = "1=地面-停车场,2=地面-路侧,3=地下停车,4=立体式停车楼") |
| | | private Integer stationOrientation; |
| | |
| | | return value; |
| | | } |
| | | String text = value.trim(); |
| | | try { |
| | | return LocalDate.parse(text, DateTimeFormatter.ISO_LOCAL_DATE).toString(); |
| | | } catch (DateTimeParseException ignored) { |
| | | // Continue with timestamp formats used by historical site data. |
| | | } |
| | | DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | try { |
| | | return OffsetDateTime.parse(text, DateTimeFormatter.ISO_OFFSET_DATE_TIME) |
| | | .atZoneSameInstant(ZoneId.of("Asia/Shanghai")).toLocalDate().toString(); |
| | | .atZoneSameInstant(ZoneId.of("Asia/Shanghai")) |
| | | .format(outputFormatter); |
| | | } catch (DateTimeParseException ignored) { |
| | | // Some records use an instant with millisecond precision and a trailing Z. |
| | | // Continue with timestamps without an explicit offset. |
| | | } |
| | | try { |
| | | return Instant.parse(text).atZone(ZoneId.of("Asia/Shanghai")).toLocalDate().toString(); |
| | | return Instant.parse(text).atZone(ZoneId.of("Asia/Shanghai")).format(outputFormatter); |
| | | } catch (DateTimeParseException ignored) { |
| | | // Continue with local datetime formats used by historical site data. |
| | | } |
| | | try { |
| | | return LocalDateTime.parse(text, DateTimeFormatter.ISO_LOCAL_DATE_TIME).format(outputFormatter); |
| | | } catch (DateTimeParseException ignored) { |
| | | // Continue with date-only values. |
| | | } |
| | | try { |
| | | return LocalDate.parse(text, DateTimeFormatter.ISO_LOCAL_DATE) |
| | | .atStartOfDay() |
| | | .format(outputFormatter); |
| | | } catch (DateTimeParseException ignored) { |
| | | // Preserve an unrecognized value rather than dropping it. |
| | | return text; |
| | | } |
| | | } |