Package google.registry.model.common
Class TimeOfYear
- java.lang.Object
-
- google.registry.model.ImmutableObject
-
- google.registry.model.common.TimeOfYear
-
- All Implemented Interfaces:
UnsafeSerializable
,java.io.Serializable
,java.lang.Cloneable
@Embeddable public class TimeOfYear extends ImmutableObject implements UnsafeSerializable
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'sPartial
, but the parts we need are too simple to justify a full implementation ofPartial
.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:
- Serialized Form
-
-
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
Constructors Constructor Description TimeOfYear()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TimeOfYear
fromDateTime(org.joda.time.DateTime dateTime)
Constructs aTimeOfYear
from aDateTime
.java.lang.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
-
-
-
-
Method Detail
-
fromDateTime
public static TimeOfYear fromDateTime(org.joda.time.DateTime dateTime)
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 java.lang.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).WARNING: This can return a potentially very large
Iterable
ifEND_OF_TIME
is used as the upper endpoint of the 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.
-
-