Skip to content

Commit 6927417

Browse files
committed
Use toNanos instead of arithmetics
1 parent ce336e9 commit 6927417

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

datastore/src/main/java/io/spine/server/storage/datastore/DsInboxStorage.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import static com.google.cloud.datastore.StructuredQuery.OrderBy.asc;
4242
import static com.google.cloud.datastore.StructuredQuery.PropertyFilter.eq;
4343
import static com.google.common.base.Preconditions.checkNotNull;
44+
import static com.google.protobuf.util.Timestamps.toNanos;
4445
import static io.spine.server.delivery.InboxMessageStatus.TO_DELIVER;
4546

4647
/**
@@ -50,8 +51,6 @@ public class DsInboxStorage
5051
extends DsMessageStorage<InboxMessageId, InboxMessage, InboxReadRequest>
5152
implements InboxStorage {
5253

53-
private static final int NANOS_PER_SECOND = 1_000_000;
54-
5554
protected DsInboxStorage(DatastoreWrapper datastore, boolean multitenant) {
5655
super(datastore, multitenant);
5756
}
@@ -150,8 +149,7 @@ private enum Column implements MessageColumn<InboxMessage> {
150149

151150
receivedAt("received_at", (m) -> {
152151
Timestamp timestamp = m.getWhenReceived();
153-
long epochNanos = timestamp.getSeconds() * NANOS_PER_SECOND + timestamp.getNanos();
154-
return LongValue.of(epochNanos);
152+
return LongValue.of(toNanos(timestamp));
155153
}),
156154

157155
version("version", (m) -> {

0 commit comments

Comments
 (0)