From 57503249a69e7e6cb4bbd2234c831b427cc63643 Mon Sep 17 00:00:00 2001 From: Alex Walker Date: Thu, 16 Sep 2021 14:36:01 +0100 Subject: [PATCH] Use ZoneOffset.UTC instead of ZoneId.of("Z") (#353) ## What is the goal of this PR? ZoneId.of("Z") is forbidden in Java 16, so we've replaced it with ZoneOffset.UTC. ## What are the changes implemented in this PR? Use ZoneOffset.UTC instead of ZoneId.of("Z") --- common/rpc/RequestBuilder.java | 3 ++- concept/thing/AttributeImpl.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/rpc/RequestBuilder.java b/common/rpc/RequestBuilder.java index 4f68a8dc80..899afb3a0e 100644 --- a/common/rpc/RequestBuilder.java +++ b/common/rpc/RequestBuilder.java @@ -38,6 +38,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; +import java.time.ZoneOffset; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -721,7 +722,7 @@ public static ConceptProto.Attribute.Value protoStringAttributeValue(String valu } public static ConceptProto.Attribute.Value protoDateTimeAttributeValue(LocalDateTime value) { - long epochMillis = value.atZone(ZoneId.of("Z")).toInstant().toEpochMilli(); + long epochMillis = value.atZone(ZoneOffset.UTC).toInstant().toEpochMilli(); return ConceptProto.Attribute.Value.newBuilder().setDateTime(epochMillis).build(); } } diff --git a/concept/thing/AttributeImpl.java b/concept/thing/AttributeImpl.java index dea1440633..a166f16a2f 100644 --- a/concept/thing/AttributeImpl.java +++ b/concept/thing/AttributeImpl.java @@ -31,6 +31,7 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; +import java.time.ZoneOffset; import java.util.stream.Stream; import static com.vaticle.typedb.client.common.exception.ErrorMessage.Concept.BAD_VALUE_TYPE; @@ -488,7 +489,7 @@ public AttributeImpl.DateTime.Remote asRemote(TypeDBTransaction transaction) { } private static LocalDateTime toLocalDateTime(long rpcDatetime) { - return LocalDateTime.ofInstant(Instant.ofEpochMilli(rpcDatetime), ZoneId.of("Z")); + return LocalDateTime.ofInstant(Instant.ofEpochMilli(rpcDatetime), ZoneOffset.UTC); } public static class Remote extends AttributeImpl.Remote implements Attribute.DateTime.Remote {