From 510bf8f373824d17d37e1096da354758bfd4ee71 Mon Sep 17 00:00:00 2001 From: jarvis Date: Tue, 29 Aug 2023 20:55:48 +0800 Subject: [PATCH] [Feature] use system timezone --- .../org/apache/seatunnel/e2e/connector/paimon/PaimonIT.java | 2 +- .../org/apache/seatunnel/format/avro/AvroToRowConverter.java | 5 +++-- .../org/apache/seatunnel/format/avro/RowToAvroConverter.java | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-paimon-e2e/src/test/java/org/apache/seatunnel/e2e/connector/paimon/PaimonIT.java b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-paimon-e2e/src/test/java/org/apache/seatunnel/e2e/connector/paimon/PaimonIT.java index 9ac072ca9c93..f9b5d6af5c01 100644 --- a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-paimon-e2e/src/test/java/org/apache/seatunnel/e2e/connector/paimon/PaimonIT.java +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-paimon-e2e/src/test/java/org/apache/seatunnel/e2e/connector/paimon/PaimonIT.java @@ -34,7 +34,7 @@ import java.nio.file.Path; @DisabledOnContainer( - value = {TestContainerId.FLINK_1_13, TestContainerId.FLINK_1_16}, + value = {TestContainerId.FLINK_1_13}, disabledReason = "Paimon does not support flink 1.13") public class PaimonIT extends TestSuiteBase { diff --git a/seatunnel-formats/seatunnel-format-avro/src/main/java/org/apache/seatunnel/format/avro/AvroToRowConverter.java b/seatunnel-formats/seatunnel-format-avro/src/main/java/org/apache/seatunnel/format/avro/AvroToRowConverter.java index 898793c2413a..70de722bf417 100644 --- a/seatunnel-formats/seatunnel-format-avro/src/main/java/org/apache/seatunnel/format/avro/AvroToRowConverter.java +++ b/seatunnel-formats/seatunnel-format-avro/src/main/java/org/apache/seatunnel/format/avro/AvroToRowConverter.java @@ -40,7 +40,7 @@ import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.ZoneOffset; +import java.time.ZoneId; import java.util.List; public class AvroToRowConverter implements Serializable { @@ -120,7 +120,8 @@ private Object convertField(SeaTunnelDataType dataType, Schema.Field field, O return LocalDate.ofEpochDay((Long) val); case TIMESTAMP: return LocalDateTime.ofInstant( - Instant.ofEpochMilli((Long) val), ZoneOffset.of("+8")); + Instant.ofEpochMilli((Long) val), + ZoneId.systemDefault()); case ROW: SeaTunnelRowType subRow = (SeaTunnelRowType) dataType; return converter((GenericRecord) val, subRow); diff --git a/seatunnel-formats/seatunnel-format-avro/src/main/java/org/apache/seatunnel/format/avro/RowToAvroConverter.java b/seatunnel-formats/seatunnel-format-avro/src/main/java/org/apache/seatunnel/format/avro/RowToAvroConverter.java index c237afdd8601..26759e662bc4 100644 --- a/seatunnel-formats/seatunnel-format-avro/src/main/java/org/apache/seatunnel/format/avro/RowToAvroConverter.java +++ b/seatunnel-formats/seatunnel-format-avro/src/main/java/org/apache/seatunnel/format/avro/RowToAvroConverter.java @@ -221,7 +221,9 @@ private Object resolveObject(Object data, SeaTunnelDataType seaTunnelDataType return recordBuilder.build(); case TIMESTAMP: LocalDateTime dateTime = (LocalDateTime) data; - return (dateTime).toInstant(ZoneOffset.of("+8")).toEpochMilli(); + return (dateTime) + .toInstant(ZoneOffset.of(ZoneOffset.systemDefault().getId())) + .toEpochMilli(); default: String errorMsg = String.format(