Skip to content

Commit

Permalink
Add option to disable daylight savings time.
Browse files Browse the repository at this point in the history
  • Loading branch information
neoremind committed Jul 17, 2020
1 parent 5290935 commit 58d7c86
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public final class ReaderSystemProperty<T> {
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<Boolean> DISABLE_DAYLIGHT_SAVINGS_TIME =
booleanProperty("innodb.java.reader.disable.daylight.savings.time",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
#innodb.java.reader.server.timezone=GMT-07:00
#innodb.java.reader.disable.daylight.savings.time=false

0 comments on commit 58d7c86

Please sign in to comment.