Package google.registry.model.common
Class TimeOfYear
java.lang.Object
google.registry.model.ImmutableObject
google.registry.model.common.TimeOfYear
- All Implemented Interfaces:
UnsafeSerializable
,Serializable
,Cloneable
A time of year (month, day, millis of day) that can be stored in a sort-friendly format.
This is conceptually similar to MonthDay
in Joda or more generally to Joda's
Partial
, but the parts we need are too simple to justify a full implementation of
Partial
.
For simplicity, the native representation of this class's data is its stored format. This allows it to be embeddable with no translation needed and also delays parsing of the string on load until it's actually needed.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class google.registry.model.ImmutableObject
ImmutableObject.DoNotHydrate, ImmutableObject.IgnoredInDiffableMap, ImmutableObject.Insignificant
-
Field Summary
Fields inherited from class google.registry.model.ImmutableObject
hashCode
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic TimeOfYear
fromDateTime
(org.joda.time.DateTime dateTime) Constructs aTimeOfYear
from aDateTime
.Iterable
<org.joda.time.DateTime> getInstancesInRange
(com.google.common.collect.Range<org.joda.time.DateTime> range) Returns anIterable
ofDateTime
s of every recurrence of this particular time of year within a givenRange
(usually one spanning many years).org.joda.time.DateTime
getLastInstanceBeforeOrAt
(org.joda.time.DateTime end) Get the firstDateTime
with this month/day/millis that is at or before the end.org.joda.time.DateTime
getNextInstanceAtOrAfter
(org.joda.time.DateTime start) Get the firstDateTime
with this month/day/millis that is at or after the start.Methods inherited from class google.registry.model.ImmutableObject
clone, cloneEmptyToNull, createVKey, equals, getSignificantFields, hashCode, toDiffableFieldMap, toHydratedString, toString, toStringHelper
-
Constructor Details
-
TimeOfYear
public TimeOfYear()
-
-
Method Details
-
fromDateTime
Constructs aTimeOfYear
from aDateTime
.This handles leap years in an intentionally peculiar way by always treating February 29 as February 28. It is impossible to construct a
TimeOfYear
for February 29th. -
getInstancesInRange
public Iterable<org.joda.time.DateTime> getInstancesInRange(com.google.common.collect.Range<org.joda.time.DateTime> range) -
getNextInstanceAtOrAfter
public org.joda.time.DateTime getNextInstanceAtOrAfter(org.joda.time.DateTime start) Get the firstDateTime
with this month/day/millis that is at or after the start. -
getLastInstanceBeforeOrAt
public org.joda.time.DateTime getLastInstanceBeforeOrAt(org.joda.time.DateTime end) Get the firstDateTime
with this month/day/millis that is at or before the end.
-