How to convert debezium Date values to java.util.Date

37 views
Skip to first unread message

Josephus Sardan

unread,
May 18, 2022, 10:06:14 AM5/18/22
to debezium
Hi,

I am using debezium connector and I am would like to ask for your help. I have set up a MySqlConnector and receiving values like below:

'beforeDate' column value: "18954" (supposed to be 2021-11-23)
'afterDate'   column value: "18953" (supposed to be 2021-11-22)

I would like above values to be converted to java.util.Date (with epoch timestamp equivalent to the dates mentioned above). 

I tried changing the config by adding below and triggering the PUT /config but when I trigger a column value change, debezium topic still produces the same value:

    "transforms.startDateConverter.field":"startDate", 
    "transforms.startDateConverter.type":"org.apache.kafka.connect.transforms.TimestampConverter$Value",
    "transforms.startDateConverter.target.type":"string", 
    "transforms.startDateConverter.format":"yyyy-MM-dd",
    "time.precision.mode":"connect"

Chris Cranford

unread,
May 18, 2022, 11:47:44 AM5/18/22
to debe...@googlegroups.com, Josephus Sardan
Hi Josephus -

This may be a silly question but you did also add this line to the connector configuration, correct:

    "transforms=startDateConverter"

Assuming you did, its likely that the TimestampConverter implementation does not work with days since epoch.  If that's the case, then you may need to introduce a CustomConverter implementation where you explicitly emit the "startDate" from Debezium with a specific format needed for your pipeline, perhaps having it emitted as a string "2021-11-23" so you don't need the TimestampConverter at all.

Hope that helps,
Chris
--
You received this message because you are subscribed to the Google Groups "debezium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to debezium+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/debezium/62f6fdc3-84d9-431a-a7f0-33e8604ea941n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages