Skip to content

Commit

Permalink
Use ZoneOffset.UTC instead of ZoneId.of("Z") (#353)
Browse files Browse the repository at this point in the history
## 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")
  • Loading branch information
alexjpwalker authored Sep 16, 2021
1 parent 1e305de commit 5750324
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion common/rpc/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Expand Down
3 changes: 2 additions & 1 deletion concept/thing/AttributeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<LocalDateTime> implements Attribute.DateTime.Remote {
Expand Down

0 comments on commit 5750324

Please sign in to comment.