alexsmolya commented on issue #1017:
URL: https://github.com/apache/fesod/issues/1017#issuecomment-5307272505
Here is an implementation proposal for `java.time.ZonedDateTime` converters,
following the established `LocalDateTime` / `LocalDate` pattern:
### 1. Proposed Converter Family
(`org.apache.fesod.sheet.converters.zoneddatetime`)
* **`ZonedDateTimeDateConverter`** (Write -> Excel `DATE` cell):
* Emits `WriteCellData(value.toLocalDateTime())` with default date format
(`yyyy-MM-dd HH:mm:ss`).
* **`ZonedDateTimeNumberConverter`** (Bidirectional Excel `NUMBER` serial):
* **Read**: Parses Excel numeric serial to `LocalDateTime` (respecting
`use1904windowing`), then assigns `ZoneId.systemDefault()`
(`localDateTime.atZone(ZoneId.systemDefault())`).
* **Write**: Converts `value.toLocalDateTime()` to numeric serial via
`DateUtil.getExcelDate(value.toLocalDateTime(), use1904)`.
* **`ZonedDateTimeStringConverter`** (Bidirectional Excel `STRING` cell):
* **Read**: Parses according to `@DateTimeFormat` if specified, or
standard `DateUtils` patterns, attaching `ZoneId.systemDefault()` when no
zone/offset is present in the input string.
* **Write**: Formats date-time using `@DateTimeFormat` (default
`yyyy-MM-dd HH:mm:ss`) and configured `Locale`.
### 2. Timezone & Lossiness Semantics
* **Numeric & Date cells**: Native Excel sheets store temporal values as
zone-less numbers/dates. Writing `ZonedDateTime` necessarily preserves the
local wall-clock time (`zonedDateTime.toLocalDateTime()`) while omitting the
`ZoneId`/offset in the Excel file.
* **Reading numeric cells**: Converts to `LocalDateTime` and attaches
`ZoneId.systemDefault()`, matching the convention used across existing `Date` /
`LocalDateTime` conversions.
* **String cells**: When explicit zone/offset patterns (e.g.
`yyyy-MM-dd'T'HH:mm:ssXXX`) are used via `@DateTimeFormat`, the offset/zone can
be parsed or emitted verbatim.
### 3. Registration & Test Coverage
* Register `ZonedDateTimeNumberConverter` and `ZonedDateTimeStringConverter`
in `DefaultConverterLoader.initAllConverter()`.
* Register `ZonedDateTimeDateConverter` and `ZonedDateTimeStringConverter`
in `DefaultConverterLoader.initDefaultWriteConverter()`.
* Add unit tests in `ConverterTest` (`supportJavaTypeKey`,
`supportExcelTypeKey`, read/write assertions for Date, Number, String).
* Add round-trip integration coverage in `ConverterDataTest` across all
supported formats (XLSX, XLS, CSV, etc.).
* Validate immutability in `DefaultConverterLoaderTest`.
Feedback and thoughts from the community are welcome!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]