mirror of
https://github.com/google/nomulus
synced 2026-05-18 13:51:45 +00:00
Migrate TMCH, SMD, and Fee models to java.time (#3019)
Continues the project-wide migration from Joda-Time's DateTime to java.time.Instant, focusing on Trademark Clearinghouse (TMCH), Signed Mark Data (SMD), and Fee extension models. Key updates: - TMCH & SMD: Updated SmdRevocationList and domain check/create flows to use Instant for sunrise validations and revocation checks. - Fee Extension Ecosystem: Refactored FeeCheckRequest, FeeCreateCommandExtension, and BaseFee to use Instant for effective dates and period calculations. - EPP Objects: Updated DomainInfoData, TransferResponse, and PollMessage objects to use Instant for event timestamps. - Pricing Logic: DomainPricingLogic methods now accept Instant for cost calculations. Additionally, DateTimeUtils was enhanced with Instant compatibility methods for plusMonths and minusMonths to safely handle leap years. Redundant conversions between DateTime and Instant were eliminated throughout the flows and tests. DomainFlowUtils leverages Instant natively to avoid inline casting, and test assertions now utilize Truth's Instant subjects for cleaner validation.
This commit is contained in:
@@ -176,6 +176,18 @@ public abstract class DateTimeUtils {
|
||||
: now.atZone(ZoneOffset.UTC).plusYears(1).plusYears(years - 1).toInstant();
|
||||
}
|
||||
|
||||
/** Adds months to a date. */
|
||||
public static Instant plusMonths(Instant now, int months) {
|
||||
checkArgument(months >= 0);
|
||||
return now.atZone(ZoneOffset.UTC).plusMonths(months).toInstant();
|
||||
}
|
||||
|
||||
/** Subtracts months from a date. */
|
||||
public static Instant minusMonths(Instant now, int months) {
|
||||
checkArgument(months >= 0);
|
||||
return now.atZone(ZoneOffset.UTC).minusMonths(months).toInstant();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts years from a date, in the {@code Duration} sense of semantic years. Use this instead
|
||||
* of {@link DateTime#minusYears} to ensure that we never end up on February 29.
|
||||
|
||||
Reference in New Issue
Block a user