Note: debezium has been upgraded and the repository is no longer maintained
Debezium custom converter is used to deal with mysql datetime type problems.
mysql | binlog-connector | debezium | schema |
---|---|---|---|
date (2021-01-28) |
LocalDate (2021-01-28) |
Integer (18655) |
io.debezium.time.Date |
time (17:29:04) |
Duration (PT17H29M4S) |
Long (62944000000) |
io.debezium.time.Time |
timestamp (2021-01-28 17:29:04) |
ZonedDateTime (2021-01-28T09:29:04Z) |
String (2021-01-28T09:29:04Z) |
io.debezium.time.ZonedTimestamp |
Datetime (2021-01-28 17:29:04) |
LocalDateTime (2021-01-28T17:29:04) |
Long (1611854944000) |
io.debezium.time.Timestamp |
For details, please refer to this article
-
Download the extended jar package and put it in the same level directory of the debezium plugin.
-
In debezium-connector, Add the following configuration:
connector.class=io.debezium.connector.mysql.MySqlConnector
# ...
converters=datetime
datetime.type=com.darcytech.debezium.converter.MySqlDateTimeConverter
datetime.format.date=yyyy-MM-dd
datetime.format.time=HH:mm:ss
datetime.format.datetime=yyyy-MM-dd HH:mm:ss
datetime.format.timestamp=yyyy-MM-dd HH:mm:ss
datetime.format.timestamp.zone=UTC+8