Class TimeOfYear

java.lang.Object
google.registry.model.ImmutableObject
google.registry.model.common.TimeOfYear
All Implemented Interfaces:
UnsafeSerializable, Serializable, 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'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:
  • Constructor Details

    • TimeOfYear

      public TimeOfYear()
  • Method Details

    • fromDateTime

      public static TimeOfYear fromDateTime(org.joda.time.DateTime dateTime)
      Constructs a TimeOfYear from a DateTime.

      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)
      Returns an Iterable of DateTimes of every recurrence of this particular time of year within a given Range (usually one spanning many years).

      WARNING: This can return a potentially very large Iterable if END_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 first DateTime 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 first DateTime with this month/day/millis that is at or before the end.