fatmanverse opened a new issue, #12797:
URL: https://github.com/apache/seatunnel/issues/12797
### Search before asking
- [x] I had searched in the issues and found no similar issues.
### What happened
The file sink with `file_format_type = "xml"` ignores `date_format`,
`datetime_format` and `time_format`. `XmlWriter#convertToXmlString` writes
DATE, TIME and TIMESTAMP values with `toString()`, while the CSV, Text and
Excel writers format them with the configured formatter.
This has two consequences:
1. The documented `datetime_format` option (default `yyyy-MM-dd HH:mm:ss`)
has no effect for XML. Timestamps are written in ISO form like
`2026-01-02T10:13:45`.
2. `LocalDateTime#toString()` omits the seconds when they are zero, so a
value like `2026-01-02 10:13:00` is written as `2026-01-02T10:13`. Within a
single file the timestamp format varies from row to row. The XML file source
cannot read such a file back with any single `datetime_format`, and fails with:
```
java.time.format.DateTimeParseException: Text '2026-01-02T10:13' could not
be parsed at index 16
```
`TIME` has the same issue (`10:13` instead of `10:13:00`).
### How to reproduce (verified on `dev` 42d2aab)
Write rows with a TIMESTAMP column whose seconds are `00` to XML, then read
the files back with the same schema:
```hocon
sink {
LocalFile {
path = "/tmp/xml_out"
file_format_type = "xml"
xml_use_attr_format = false
# sink-side format options take the enum name
datetime_format = "YYYY_MM_DD_HH_MM_SS"
}
}
```
The written file contains `<c_timestamp>2026-01-02T10:13</c_timestamp>`
instead of `2026-01-02 10:13:00`; the option has no effect. In a 3000-row
round-trip test (MySQL -> XML -> MySQL), 150 timestamps were written without
seconds and the XML source job failed.
### Expected behavior
The XML writer formats DATE, TIME and TIMESTAMP with `date_format`,
`time_format` and `datetime_format`, the same way the CSV, Text and Excel
writers do. The output can then be read back by the XML source using the same
options.
### SeaTunnel Version
dev (3.0.1-SNAPSHOT, 42d2aab)
### Zeta or Flink or Spark Version
Zeta
### Java or Scala Version
JDK 11
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
--
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]