Repository navigation
Conversation
740299a to
071c1da
Compare
|
Thanks @Mikkey-f for the clear reproduction steps. This one is easy to verify. I pulled the branch and ran a small standalone probe locally on Windows 10 Pro with Microsoft OpenJDK 21.0.10. Everything compiles and runs cleanly on my side. On the branch without this change, the CSV contains I ran into a closely related limitation in an earlier PR of mine. An Excel numeric date cell carries no locale information, so a write then read round trip only reconstructs the wall clock value, and localized text appears only where the value is rendered as a string. The same root cause shows up here with the offset. The value carries its offset when it is written, but an Excel DATE cell has nowhere to record it. On the read side the offset is either lost or replaced with the system default zone. I agree with the direction in this PR. When the offset needs to survive, a string representation is the way to go. Keeping the read side strict, documenting the DATE cell limitation, and making the default CSV output readable back all look right to me. LGTM from my side. |
Purpose of the pull request
Closed: #1334
OffsetDateTimeDateConverterwrites DATE cells that contain only the local date-time. A CSV file therefore containedyyyy-MM-dd HH:mm:sswithout an offset, and reading it back into a plainOffsetDateTimefield failed inOffsetDateTimeStringConverter, whose default parser is strictISO_OFFSET_DATE_TIME.What's changed?
OffsetDateTimeDateConverternow overridesconvertToExcelData(WriteConverterContext)and, for CSV without an explicit@DateTimeFormat, writes an ISO-8601 string with the offset (ISO_OFFSET_DATE_TIME). The value is read back unchanged by the existing strictOffsetDateTimeStringConverter. This follows the second option in [Bug] OffsetDateTimeDateConverter drops the offset and its CSV output cannot be read back #1334 (write an ISO string that carries the offset) and keeps the read side strict.@DateTimeFormatkeeps the existing DATE-cell behavior on CSV; useOffsetDateTimeStringConverterwhen a custom representation must carry the offset.OffsetDateTimeStringConverterandDateUtilsare unchanged; parsing stays strict, as requested in feat: add ZonedDateTime converters #1020.Verification:
OffsetDateTimeConverterTest+OffsetDateTimeDateRoundTripTest: 14 + 3 passed.ExcelDataConvertException); the XLSX/XLS cases still pass without it.fesod-common60 +fesod-sheet1,820, 0 failures / 0 errors / 0 skipped.spotless:checkandjavadoc:javadocpass.Checklist