This is an automated email from the ASF dual-hosted git repository.

fcsaky pushed a commit to branch release-1.19
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.19 by this push:
     new 53ce107cdd9 [FLINK-35482][parquet][test] Fix timezone handling in 
ParquetInt64TimestampReaderTest
53ce107cdd9 is described below

commit 53ce107cdd9b0866215d9450aa1ae02641c07d1c
Author: Tamas Sule <[email protected]>
AuthorDate: Fri Aug 23 16:36:18 2024 +0200

    [FLINK-35482][parquet][test] Fix timezone handling in 
ParquetInt64TimestampReaderTest
---
 .../vector/ParquetInt64TimestampReaderTest.java    | 35 ++++++++++------------
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git 
a/flink-formats/flink-parquet/src/test/java/org/apache/flink/formats/parquet/vector/ParquetInt64TimestampReaderTest.java
 
b/flink-formats/flink-parquet/src/test/java/org/apache/flink/formats/parquet/vector/ParquetInt64TimestampReaderTest.java
index 96a0c5104a0..72e93f0bfca 100644
--- 
a/flink-formats/flink-parquet/src/test/java/org/apache/flink/formats/parquet/vector/ParquetInt64TimestampReaderTest.java
+++ 
b/flink-formats/flink-parquet/src/test/java/org/apache/flink/formats/parquet/vector/ParquetInt64TimestampReaderTest.java
@@ -22,48 +22,45 @@ import 
org.apache.flink.formats.parquet.vector.reader.TimestampColumnReader;
 import org.apache.flink.table.data.TimestampData;
 
 import org.apache.parquet.schema.LogicalTypeAnnotation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import java.time.LocalDateTime;
-import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
 
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** Test for {@link TimestampColumnReader}. */
 public class ParquetInt64TimestampReaderTest {
     @Test
     public void testReadInt64TimestampMicros() {
-        LocalDateTime localDateTime = LocalDateTime.of(2021, 11, 22, 17, 50, 
20, 112233);
-        long time =
-                localDateTime.toEpochSecond(OffsetDateTime.now().getOffset()) 
* 1_000_000
-                        + localDateTime.getNano() / 1_000;
+        ZonedDateTime zonedDateTime =
+                ZonedDateTime.of(2021, 11, 22, 17, 50, 20, 112233, 
ZoneOffset.systemDefault());
+        long time = zonedDateTime.toEpochSecond() * 1_000_000 + 
zonedDateTime.getNano() / 1_000;
         TimestampData timestampData =
                 TimestampColumnReader.int64ToTimestamp(
                         false, time, LogicalTypeAnnotation.TimeUnit.MICROS);
-        assertEquals("2021-11-22T17:50:20.000112", timestampData.toString());
+        
assertThat(timestampData.toString()).isEqualTo("2021-11-22T17:50:20.000112");
     }
 
     @Test
     public void testReadInt64TimestampMillis() {
-        LocalDateTime localDateTime = LocalDateTime.of(2021, 11, 22, 17, 50, 
20, 112233);
-        long time =
-                localDateTime.toEpochSecond(OffsetDateTime.now().getOffset()) 
* 1_000
-                        + localDateTime.getNano() / 1_000_000;
+        ZonedDateTime zonedDateTime =
+                ZonedDateTime.of(2021, 11, 22, 17, 50, 20, 112233, 
ZoneOffset.systemDefault());
+        long time = zonedDateTime.toEpochSecond() * 1000 + 
zonedDateTime.getNano() / 1_000_000;
         TimestampData timestampData =
                 TimestampColumnReader.int64ToTimestamp(
                         false, time, LogicalTypeAnnotation.TimeUnit.MILLIS);
-        assertEquals("2021-11-22T17:50:20", timestampData.toString());
+        assertThat(timestampData.toString()).isEqualTo("2021-11-22T17:50:20");
     }
 
     @Test
     public void testReadInt64TimestampNanos() {
-        LocalDateTime localDateTime = LocalDateTime.of(2021, 11, 22, 17, 50, 
20, 112233);
-        long time =
-                localDateTime.toEpochSecond(OffsetDateTime.now().getOffset()) 
* 1_000_000_000
-                        + localDateTime.getNano();
+        ZonedDateTime zonedDateTime =
+                ZonedDateTime.of(2021, 11, 22, 17, 50, 20, 112233, 
ZoneOffset.systemDefault());
+        long time = zonedDateTime.toEpochSecond() * 1_000_000_000 + 
zonedDateTime.getNano();
         TimestampData timestampData =
                 TimestampColumnReader.int64ToTimestamp(
                         false, time, LogicalTypeAnnotation.TimeUnit.NANOS);
-        assertEquals("2021-11-22T17:50:20.000112233", 
timestampData.toString());
+        
assertThat(timestampData.toString()).isEqualTo("2021-11-22T17:50:20.000112233");
     }
 }

Reply via email to