1
0
mirror of https://github.com/google/nomulus synced 2026-05-19 14:21:48 +00:00

Set clock precision to milliseconds for Datetime->Instant migration (#2999)

Our existing precision is milliseconds so we want to stick with that for
Instants. If we want to increase the precision globally after that we can do so
all in one go post-migration, but for now, it would be a bad thing to have mixed
precision going on just depending on whether a class happens to be migrated yet
or not.

This PR also migrates all existing DateTime.nowUtc() calls to use the Clock
interface, so that when they are migrated they will get the benefit of this
precision-setting as well.

BUG= http://b/496985355
This commit is contained in:
Ben McIlwain
2026-04-03 16:38:26 -04:00
committed by GitHub
parent d2881b47dc
commit 49f14b5e1b
69 changed files with 466 additions and 320 deletions

View File

@@ -16,6 +16,8 @@ package google.registry.util;
import java.io.Serializable;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import javax.annotation.concurrent.ThreadSafe;
import org.joda.time.DateTime;
@@ -36,4 +38,9 @@ public interface Clock extends Serializable {
/** Returns current Instant (which is always in UTC). */
Instant now();
/** Returns the current time as a {@link ZonedDateTime} in UTC. */
default ZonedDateTime nowDate() {
return ZonedDateTime.ofInstant(now(), ZoneOffset.UTC);
}
}