Package google.registry.util
Class DateTimeUtils
java.lang.Object
google.registry.util.DateTimeUtils
Utilities methods and constants related to Joda
DateTime
objects.-
Field Summary
Modifier and TypeFieldDescriptionstatic 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
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.joda.time.DateTime
earliestOf
(Iterable<org.joda.time.DateTime> dates) Returns the earliest element in aDateTime
iterable.static org.joda.time.DateTime
earliestOf
(org.joda.time.DateTime first, org.joda.time.DateTime... rest) Returns the earliest of a number of givenDateTime
instances.static boolean
isAtOrAfter
(org.joda.time.DateTime timeToCheck, org.joda.time.DateTime timeToCompareTo) Returns whether the firstDateTime
is equal to or later than the second.static boolean
isBeforeOrAt
(org.joda.time.DateTime timeToCheck, org.joda.time.DateTime timeToCompareTo) Returns whether the firstDateTime
is equal to or earlier than the second.static org.joda.time.DateTime
Returns the latest element in aDateTime
iterable.static org.joda.time.DateTime
latestOf
(org.joda.time.DateTime first, org.joda.time.DateTime... rest) Returns the latest of a number of givenDateTime
instances.static org.joda.time.DateTime
leapSafeAddYears
(org.joda.time.DateTime now, int years) Adds years to a date, in theDuration
sense of semantic years.static org.joda.time.DateTime
leapSafeSubtractYears
(org.joda.time.DateTime now, int years) Subtracts years from a date, in theDuration
sense of semantic years.static org.joda.time.LocalDate
toLocalDate
(Date date) static Date
toSqlDate
(org.joda.time.LocalDate localDate)
-
Field Details
-
START_OF_TIME
public static final org.joda.time.DateTime START_OF_TIMEThe start of the epoch, in a convenient constant. -
END_OF_TIME
public static final org.joda.time.DateTime END_OF_TIMEA 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 givenDateTime
instances. -
earliestOf
Returns the earliest element in aDateTime
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 givenDateTime
instances. -
latestOf
Returns the latest element in aDateTime
iterable. -
isBeforeOrAt
public static boolean isBeforeOrAt(org.joda.time.DateTime timeToCheck, org.joda.time.DateTime timeToCompareTo) Returns whether the firstDateTime
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 firstDateTime
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 theDuration
sense of semantic years. Use this instead ofDateTime.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 theDuration
sense of semantic years. Use this instead ofDateTime.minusYears(int)
to ensure that we never end up on February 29. -
toSqlDate
-
toLocalDate
-