Class DateTimeUtils

java.lang.Object
google.registry.util.DateTimeUtils

public abstract class DateTimeUtils extends Object
Utilities methods and constants related to Joda DateTime objects.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.joda.time.DateTime
    A date in the far future that we can treat as infinity.
    static final org.joda.time.DateTime
    The start of the epoch, in a convenient constant.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.joda.time.DateTime
    earliestOf(Iterable<org.joda.time.DateTime> dates)
    Returns the earliest element in a DateTime iterable.
    static org.joda.time.DateTime
    earliestOf(org.joda.time.DateTime first, org.joda.time.DateTime... rest)
    Returns the earliest of a number of given DateTime instances.
    static boolean
    isAtOrAfter(org.joda.time.DateTime timeToCheck, org.joda.time.DateTime timeToCompareTo)
    Returns whether the first DateTime is equal to or later than the second.
    static boolean
    isBeforeOrAt(org.joda.time.DateTime timeToCheck, org.joda.time.DateTime timeToCompareTo)
    Returns whether the first DateTime is equal to or earlier than the second.
    static org.joda.time.DateTime
    latestOf(Iterable<org.joda.time.DateTime> dates)
    Returns the latest element in a DateTime iterable.
    static org.joda.time.DateTime
    latestOf(org.joda.time.DateTime first, org.joda.time.DateTime... rest)
    Returns the latest of a number of given DateTime instances.
    static org.joda.time.DateTime
    leapSafeAddYears(org.joda.time.DateTime now, int years)
    Adds years to a date, in the Duration sense of semantic years.
    static org.joda.time.DateTime
    leapSafeSubtractYears(org.joda.time.DateTime now, int years)
    Subtracts years from a date, in the Duration sense of semantic years.
    static org.joda.time.LocalDate
     
    static Date
    toSqlDate(org.joda.time.LocalDate localDate)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • START_OF_TIME

      public static final org.joda.time.DateTime START_OF_TIME
      The start of the epoch, in a convenient constant.
    • END_OF_TIME

      public static final org.joda.time.DateTime END_OF_TIME
      A date in the far future that we can treat as infinity.

      This value is (2^63-1)/1000 rounded down. AppEngine stores dates as 64 bit microseconds, but Java uses milliseconds, so this is the largest representable date that will survive a round-trip through the database.

  • Constructor Details

    • DateTimeUtils

      public DateTimeUtils()
  • Method Details

    • earliestOf

      public static org.joda.time.DateTime earliestOf(org.joda.time.DateTime first, org.joda.time.DateTime... rest)
      Returns the earliest of a number of given DateTime instances.
    • earliestOf

      public static org.joda.time.DateTime earliestOf(Iterable<org.joda.time.DateTime> dates)
      Returns the earliest element in a DateTime iterable.
    • latestOf

      public static org.joda.time.DateTime latestOf(org.joda.time.DateTime first, org.joda.time.DateTime... rest)
      Returns the latest of a number of given DateTime instances.
    • latestOf

      public static org.joda.time.DateTime latestOf(Iterable<org.joda.time.DateTime> dates)
      Returns the latest element in a DateTime iterable.
    • isBeforeOrAt

      public static boolean isBeforeOrAt(org.joda.time.DateTime timeToCheck, org.joda.time.DateTime timeToCompareTo)
      Returns whether the first DateTime is equal to or earlier than the second.
    • isAtOrAfter

      public static boolean isAtOrAfter(org.joda.time.DateTime timeToCheck, org.joda.time.DateTime timeToCompareTo)
      Returns whether the first DateTime is equal to or later than the second.
    • leapSafeAddYears

      public static org.joda.time.DateTime leapSafeAddYears(org.joda.time.DateTime now, int years)
      Adds years to a date, in the Duration sense of semantic years. Use this instead of DateTime.plusYears(int) to ensure that we never end up on February 29.
    • leapSafeSubtractYears

      public static org.joda.time.DateTime leapSafeSubtractYears(org.joda.time.DateTime now, int years)
      Subtracts years from a date, in the Duration sense of semantic years. Use this instead of DateTime.minusYears(int) to ensure that we never end up on February 29.
    • toSqlDate

      public static Date toSqlDate(org.joda.time.LocalDate localDate)
    • toLocalDate

      public static org.joda.time.LocalDate toLocalDate(Date date)