clickhouse-sink-connector icon indicating copy to clipboard operation
clickhouse-sink-connector copied to clipboard

Use zoned time when parse string

Open IlyaTsoi opened this issue 1 year ago • 2 comments

I suggest to use ZonedDateTime instead of LocalDateTime. So we can parse a time_string with an offset marker e.g. +03:00, -0130, Z. Also we can handle an exception when a dateTime string has invalid year e.g. in MSSQL "0000-00-01 00:00:00". Zero year value is invalid in java.

IlyaTsoi avatar Oct 25 '23 09:10 IlyaTsoi

Maybe it can solve #215?

IlyaTsoi avatar Oct 25 '23 12:10 IlyaTsoi

Please add to this test case like this

    @Test
    public void testZonedTimestampConverter() {

        String formattedTimestamp = DebeziumConverter.ZonedTimestampConverter.convert("2021-12-31T19:01:00Z");
        Assert.assertTrue(formattedTimestamp.equalsIgnoreCase("2021-12-31 19:01:00.000000"));

        String formattedTimestampWMicroSeconds = DebeziumConverter.ZonedTimestampConverter.convert("2038-01-19T03:14:07.999999Z");
        Assert.assertTrue(formattedTimestampWMicroSeconds.equalsIgnoreCase("2038-01-19 03:14:07.999999"));

        String formattedTimestamp3 = DebeziumConverter.ZonedTimestampConverter.convert("2038-01-19T03:14:07.99Z");
        Assert.assertTrue(formattedTimestamp3.equalsIgnoreCase("2038-01-19 03:14:07.990000"));

        String formattedTimestamp4 = DebeziumConverter.ZonedTimestampConverter.convert("0000-00-01 00:00:00");
        System.out.println(formattedTimestamp4);
    }

subkanthi avatar Oct 25 '23 15:10 subkanthi

This was implemented as part of other PR's , closing this for now.

subkanthi avatar Jul 31 '24 20:07 subkanthi