diff --git a/airbyte-db/db-lib/src/main/java/io/airbyte/db/DataTypeUtils.java b/airbyte-db/db-lib/src/main/java/io/airbyte/db/DataTypeUtils.java index 57e9dd3efe1b..6e82d77a8fc4 100644 --- a/airbyte-db/db-lib/src/main/java/io/airbyte/db/DataTypeUtils.java +++ b/airbyte-db/db-lib/src/main/java/io/airbyte/db/DataTypeUtils.java @@ -31,6 +31,7 @@ public class DataTypeUtils { public static final DateTimeFormatter TIMETZ_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss.SSSSSSXXX"); public static final DateTimeFormatter TIMESTAMPTZ_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX"); public static final DateTimeFormatter OFFSETDATETIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS XXX"); + public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // wrap SimpleDateFormat in a function because SimpleDateFormat is not threadsafe as a static final. public static DateFormat getDateFormat() { diff --git a/airbyte-db/db-lib/src/main/java/io/airbyte/db/jdbc/DateTimeConverter.java b/airbyte-db/db-lib/src/main/java/io/airbyte/db/jdbc/DateTimeConverter.java index a2340afcfc55..9a3f4c33feb0 100644 --- a/airbyte-db/db-lib/src/main/java/io/airbyte/db/jdbc/DateTimeConverter.java +++ b/airbyte-db/db-lib/src/main/java/io/airbyte/db/jdbc/DateTimeConverter.java @@ -4,6 +4,7 @@ package io.airbyte.db.jdbc; +import static io.airbyte.db.DataTypeUtils.DATE_FORMATTER; import static io.airbyte.db.DataTypeUtils.TIMESTAMPTZ_FORMATTER; import static io.airbyte.db.DataTypeUtils.TIMESTAMP_FORMATTER; import static io.airbyte.db.DataTypeUtils.TIMETZ_FORMATTER; @@ -101,10 +102,7 @@ public static String convertToDate(final Object date) { return resolveEra(d, localDate.toString()); } else if (date instanceof LocalDate d) { // Incremental mode - if (isBce(d)) { - d = d.minusYears(1); - } - return resolveEra(d, d.toString()); + return resolveEra(d, d.format(DATE_FORMATTER)); } else { final LocalDate localDate = LocalDate.parse(date.toString()); return resolveEra(localDate, localDate.toString());