Skip to content

Commit

Permalink
use formatter for dates also (#15485)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgao authored Aug 10, 2022
1 parent 98ad23b commit 49ae556
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 49ae556

Please sign in to comment.