Class DateTimes

java.lang.Object
org.apache.druid.java.util.common.DateTimes

public final class DateTimes extends Object
  • Field Details

    • EPOCH

      public static final org.joda.time.DateTime EPOCH
    • MAX

      public static final org.joda.time.DateTime MAX
    • MIN

      public static final org.joda.time.DateTime MIN
    • COMPARE_DATE_AS_STRING_MIN

      public static final org.joda.time.DateTime COMPARE_DATE_AS_STRING_MIN
    • COMPARE_DATE_AS_STRING_MAX

      public static final org.joda.time.DateTime COMPARE_DATE_AS_STRING_MAX
    • ISO_DATE_TIME

      public static final DateTimes.UtcFormatter ISO_DATE_TIME
    • ISO_DATE_OPTIONAL_TIME

      public static final DateTimes.UtcFormatter ISO_DATE_OPTIONAL_TIME
    • ISO_DATE_OR_TIME_WITH_OFFSET

      public static final DateTimes.UtcFormatter ISO_DATE_OR_TIME_WITH_OFFSET
    • COMMON_DATE_TIME_PATTERN

      public static final Pattern COMMON_DATE_TIME_PATTERN
      This pattern aims to match strings, produced by AbstractDateTime.toString(). It's not rigorous: it could accept some strings that couldn't be obtained by calling toString() on any DateTime object, and also it could not match some valid DateTime string. Use for heuristic purposes only.
  • Method Details

    • inferTzFromString

      public static org.joda.time.DateTimeZone inferTzFromString(String tzId)
    • inferTzFromString

      public static org.joda.time.DateTimeZone inferTzFromString(String tzId, boolean fallback) throws IllegalArgumentException
      Returns:
      The dateTimezone for the provided . If is true, the default timezone will be returned if the tzId does not match a supported timezone.
      Throws:
      IllegalArgumentException - if is false and the provided tzId doesn't match a supported timezone.
    • wrapFormatter

      public static DateTimes.UtcFormatter wrapFormatter(org.joda.time.format.DateTimeFormatter formatter)
      Creates a DateTimes.UtcFormatter that wraps around a DateTimeFormatter.
      Parameters:
      formatter - inner DateTimeFormatter used to parse String
    • utc

      public static org.joda.time.DateTime utc(long instant)
    • of

      public static org.joda.time.DateTime of(String instant)
    • of

      public static org.joda.time.DateTime of(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)
    • nowUtc

      public static org.joda.time.DateTime nowUtc()
    • max

      public static org.joda.time.DateTime max(org.joda.time.DateTime dt1, org.joda.time.DateTime dt2)
    • min

      public static org.joda.time.DateTime min(org.joda.time.DateTime dt1, org.joda.time.DateTime dt2)
    • subMonths

      public static int subMonths(long timestamp1, long timestamp2, org.joda.time.DateTimeZone timeZone)
    • canCompareAsString

      public static boolean canCompareAsString(org.joda.time.DateTime dateTime)
      Returns true if the provided DateTime can be compared against other DateTimes using its string representation. Useful when generating SQL queries to the metadata store, or any other situation where time comparisons on string representations might be useful. Conditions: the datetime must be between years 0 and 9999 (inclusive) and must be in the ISO UTC chronology. See also Intervals.canCompareEndpointsAsStrings(Interval).
    • earlierOf

      public static org.joda.time.DateTime earlierOf(org.joda.time.DateTime a, org.joda.time.DateTime b)
      Returns the earlier of the two given dates. When passed a null and a non-null date, this method simply returns the non-null value.
    • laterOf

      public static org.joda.time.DateTime laterOf(org.joda.time.DateTime a, org.joda.time.DateTime b)
      Returns the later of the two given dates. When passed a null and a non-null date, this method simply returns the non-null value.