Skip to content

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

Open
CydeWeys wants to merge 1 commit intogoogle:masterfrom
CydeWeys:datetime2-clock-precision
Open

Set clock precision to milliseconds for Datetime->Instant migration#2999
CydeWeys wants to merge 1 commit intogoogle:masterfrom
CydeWeys:datetime2-clock-precision

Conversation

@CydeWeys
Copy link
Copy Markdown
Member

@CydeWeys CydeWeys commented Mar 31, 2026

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 change is Reviewable

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
@CydeWeys CydeWeys requested a review from gbrodman March 31, 2026 21:49
AtomicInteger hardDeletedDomains = new AtomicInteger();
AtomicReference<ImmutableList<Domain>> domainsBatch = new AtomicReference<>();
DateTime startTime = DateTime.now(UTC);
DateTime startTime = clock.nowUtc();

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
Clock.nowUtc
should be avoided because it has been deprecated.

// Automatically kill the job if it is running for over 20 hours
} while (DateTime.now(UTC).isBefore(startTime.plusHours(20))
} while (clock.nowUtc().isBefore(startTime.plusHours(20))

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
Clock.nowUtc
should be avoided because it has been deprecated.
updateLastNotificationSentDate(
registrar,
DateTime.now(UTC).minusMinutes((int) UPDATE_TIME_OFFSET.getStandardMinutes()),
clock.nowUtc().minusMinutes((int) UPDATE_TIME_OFFSET.getStandardMinutes()),

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
Clock.nowUtc
should be avoided because it has been deprecated.

public Builder timeToLive(Duration duration) {
this.table.setExpirationTime(DateTime.now(UTC).plus(duration).getMillis());
this.table.setExpirationTime(clock.nowUtc().plus(duration).getMillis());

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
Clock.nowUtc
should be avoided because it has been deprecated.
() ->
save(
PremiumListUtils.parseToPremiumList(
name, currencyUnit, inputData, tm().getTransactionTime())));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
TransactionManager.getTransactionTime
should be avoided because it has been deprecated.
consoleApiParams
.response()
.setDateHeader("Expires", DateTime.now(UTC).withTimeAtStartOfDay().plusDays(1));
.setDateHeader("Expires", clock.nowUtc().withTimeAtStartOfDay().plusDays(1));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
Clock.nowUtc
should be avoided because it has been deprecated.
keyGen.generateKeyPair(), DEFAULT_ISSUER_FQDN, DEFAULT_NOT_BEFORE, DEFAULT_NOT_AFTER);
keyGen.generateKeyPair(),
DEFAULT_ISSUER_FQDN,
clock.nowUtc().minusHours(1),

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
Clock.nowUtc
should be avoided because it has been deprecated.
keyGen.generateKeyPair(),
DEFAULT_ISSUER_FQDN,
clock.nowUtc().minusHours(1),
clock.nowUtc().plusDays(1));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
Clock.nowUtc
should be avoided because it has been deprecated.
public static SelfSignedCaCertificate create(String fqdn) throws Exception {
return create(fqdn, DEFAULT_NOT_BEFORE, DEFAULT_NOT_AFTER);
public static SelfSignedCaCertificate create(String fqdn, Clock clock) throws Exception {
return create(fqdn, clock.nowUtc().minusHours(1), clock.nowUtc().plusDays(1));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
Clock.nowUtc
should be avoided because it has been deprecated.
public static SelfSignedCaCertificate create(String fqdn) throws Exception {
return create(fqdn, DEFAULT_NOT_BEFORE, DEFAULT_NOT_AFTER);
public static SelfSignedCaCertificate create(String fqdn, Clock clock) throws Exception {
return create(fqdn, clock.nowUtc().minusHours(1), clock.nowUtc().plusDays(1));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
Clock.nowUtc
should be avoided because it has been deprecated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants