From c5063da76854f0a27cdcfffcc5573aca7632a1c2 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 | 4 ++-- .../org/apache/seatunnel/format/avro/RowToAvroConverter.java | 4 ++-- 3 files changed, 5 insertions(+), 5 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 9ac072ca9c9..f9b5d6af5c0 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 898793c2413..296ce6eef57 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,7 @@ 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 c237afdd860..b1bd3360177 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 @@ -42,7 +42,7 @@ import java.nio.ByteBuffer; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.ZoneOffset; +import java.time.ZoneId; import java.util.ArrayList; import java.util.List; @@ -221,7 +221,7 @@ 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).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); default: String errorMsg = String.format(