Class DateTimes
java.lang.Object
org.apache.druid.java.util.common.DateTimes
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSimple wrapper class to enforce UTC Chronology in formatter. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternThis pattern aims to match strings, produced byAbstractDateTime.toString().static final org.joda.time.DateTimestatic final org.joda.time.DateTimestatic final org.joda.time.DateTimestatic final DateTimes.UtcFormatterstatic final DateTimes.UtcFormatterstatic final DateTimes.UtcFormatterstatic final org.joda.time.DateTimestatic final org.joda.time.DateTime -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanCompareAsString(org.joda.time.DateTime dateTime) Returns true if the provided DateTime can be compared against other DateTimes using its string representation.static org.joda.time.DateTimeearlierOf(org.joda.time.DateTime a, org.joda.time.DateTime b) Returns the earlier of the two given dates.static org.joda.time.DateTimeZoneinferTzFromString(String tzId) static org.joda.time.DateTimeZoneinferTzFromString(String tzId, boolean fallback) static org.joda.time.DateTimelaterOf(org.joda.time.DateTime a, org.joda.time.DateTime b) Returns the later of the two given dates.static org.joda.time.DateTimemax(org.joda.time.DateTime dt1, org.joda.time.DateTime dt2) static org.joda.time.DateTimemin(org.joda.time.DateTime dt1, org.joda.time.DateTime dt2) static org.joda.time.DateTimenowUtc()static org.joda.time.DateTimeof(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour) static org.joda.time.DateTimestatic intsubMonths(long timestamp1, long timestamp2, org.joda.time.DateTimeZone timeZone) static org.joda.time.DateTimeutc(long instant) static DateTimes.UtcFormatterwrapFormatter(org.joda.time.format.DateTimeFormatter formatter) Creates aDateTimes.UtcFormatterthat wraps around aDateTimeFormatter.
-
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
-
ISO_DATE_OPTIONAL_TIME
-
ISO_DATE_OR_TIME_WITH_OFFSET
-
COMMON_DATE_TIME_PATTERN
This pattern aims to match strings, produced byAbstractDateTime.toString(). It's not rigorous: it could accept some strings that couldn't be obtained by calling toString() on anyDateTimeobject, and also it could not match some valid DateTime string. Use for heuristic purposes only.
-
-
Method Details
-
inferTzFromString
-
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 aDateTimes.UtcFormatterthat wraps around aDateTimeFormatter.- Parameters:
formatter- innerDateTimeFormatterused to parseString
-
utc
public static org.joda.time.DateTime utc(long instant) -
of
-
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 alsoIntervals.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.
-