From 58d7c86fdb38ea4100652c5bce639322649ae967 Mon Sep 17 00:00:00 2001 From: xu Date: Fri, 17 Jul 2020 11:20:58 -0400 Subject: [PATCH] Add option to disable daylight savings time. --- .../innodb/java/reader/config/ReaderSystemProperty.java | 3 ++- .../com/alibaba/innodb/java/reader/AbstractTest.java | 9 ++++++++- .../src/test/resources/innodb-java-reader.properties | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/innodb-java-reader/src/main/java/com/alibaba/innodb/java/reader/config/ReaderSystemProperty.java b/innodb-java-reader/src/main/java/com/alibaba/innodb/java/reader/config/ReaderSystemProperty.java index 7839c70..ee6abdf 100644 --- a/innodb-java-reader/src/main/java/com/alibaba/innodb/java/reader/config/ReaderSystemProperty.java +++ b/innodb-java-reader/src/main/java/com/alibaba/innodb/java/reader/config/ReaderSystemProperty.java @@ -107,7 +107,8 @@ public final class ReaderSystemProperty { stringProperty("innodb.java.reader.server.timezone", ""); /** - * Whether to ignore daylight savings time when converting TIMESTAMP type. + * If server timezone is not set, this indicates whether to ignore + * daylight savings time when converting TIMESTAMP type. */ public static final ReaderSystemProperty DISABLE_DAYLIGHT_SAVINGS_TIME = booleanProperty("innodb.java.reader.disable.daylight.savings.time", diff --git a/innodb-java-reader/src/test/java/com/alibaba/innodb/java/reader/AbstractTest.java b/innodb-java-reader/src/test/java/com/alibaba/innodb/java/reader/AbstractTest.java index a94d756..537174f 100644 --- a/innodb-java-reader/src/test/java/com/alibaba/innodb/java/reader/AbstractTest.java +++ b/innodb-java-reader/src/test/java/com/alibaba/innodb/java/reader/AbstractTest.java @@ -28,6 +28,7 @@ import java.util.Iterator; import java.util.List; import java.util.Properties; +import java.util.TimeZone; import java.util.function.Consumer; import java.util.function.Function; @@ -342,7 +343,13 @@ private static Properties loadProperties() { } protected static String expectedLocalTime(String dateTime) { - ZoneRules rules = ZoneId.systemDefault().getRules(); + String zoneId; + if (StringUtils.isNotEmpty(ReaderSystemProperty.SERVER_TIME_ZONE.value())) { + zoneId = TimeZone.getTimeZone(ReaderSystemProperty.SERVER_TIME_ZONE.value().trim()).getID(); + } else { + zoneId = ZoneId.systemDefault().getId(); + } + ZoneRules rules = ZoneId.of(zoneId).getRules(); LocalDateTime ldt = Utils.parseDateTimeText(dateTime); Instant instant = ldt.toInstant(ZoneOffset.of("+00:00")); ZoneOffset zoneOffset; diff --git a/innodb-java-reader/src/test/resources/innodb-java-reader.properties b/innodb-java-reader/src/test/resources/innodb-java-reader.properties index 08ea608..ea17e4b 100644 --- a/innodb-java-reader/src/test/resources/innodb-java-reader.properties +++ b/innodb-java-reader/src/test/resources/innodb-java-reader.properties @@ -2,4 +2,5 @@ innodb.java.reader.enable.file.length.check=true innodb.java.reader.enable.throw.exception.for.unsupported.mysql80.lob=false innodb.java.reader.enable.page.checksum.check=true -#innodb.java.reader.server.timezone=GMT-07:00 \ No newline at end of file +#innodb.java.reader.server.timezone=GMT-07:00 +#innodb.java.reader.disable.daylight.savings.time=false \ No newline at end of file