diff --git a/src/main/java/oryanmoshe/kafka/connect/util/TimestampConverter.java b/src/main/java/oryanmoshe/kafka/connect/util/TimestampConverter.java index 8c87252..556aed5 100644 --- a/src/main/java/oryanmoshe/kafka/connect/util/TimestampConverter.java +++ b/src/main/java/oryanmoshe/kafka/connect/util/TimestampConverter.java @@ -2,26 +2,24 @@ import io.debezium.spi.converter.CustomConverter; import io.debezium.spi.converter.RelationalColumn; +import org.apache.kafka.connect.data.SchemaBuilder; -import java.text.SimpleDateFormat; import java.time.Instant; -import java.util.Date; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.kafka.connect.data.SchemaBuilder; - public class TimestampConverter implements CustomConverter { private static final Map MONTH_MAP = Map.ofEntries(Map.entry("jan", "01"), Map.entry("feb", "02"), Map.entry("mar", "03"), Map.entry("apr", "04"), Map.entry("may", "05"), Map.entry("jun", "06"), Map.entry("jul", "07"), Map.entry("aug", "08"), Map.entry("sep", "09"), Map.entry("oct", "10"), Map.entry("nov", "11"), Map.entry("dec", "12")); - public static final int MILLIS_LENGTH = 13; public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; public static final String DEFAULT_DATE_FORMAT = "YYYY-MM-dd"; @@ -30,36 +28,35 @@ public class TimestampConverter implements CustomConverter SUPPORTED_DATA_TYPES = List.of("date", "time", "datetime", "timestamp", "datetime2"); - private static final String DATETIME_REGEX = "(?(?(?:(?\\d{4})-(?\\d{1,2})-(?\\d{1,2}))|(?:(?\\d{1,2})\\/(?\\d{1,2})\\/(?\\d{4}))|(?:(?\\d{1,2})-(?\\w{3})-(?\\d{4})))?(?:\\s?T?(?