deephaven.DBTimeUtils

Utilities for Deephaven date/time storage and manipulation.

DAY = 86400000000000

One day in nanoseconds.

DBDateTime = None

Deephaven date-time class (com.illumon.iris.db.tables.utils.DBDateTime).

DBTimeZone = None

Deephaven timezone class (com.illumon.iris.db.tables.utils.DBTimeZone).

HOUR = 3600000000000

One hour in nanoseconds.

MINUTE = 60000000000

One minute in nanoseconds.

SECOND = 1000000000

One second in nanoseconds.

WEEK = 604800000000000

One week in nanoseconds.

YEAR = 31449600000000000

One year in nanoseconds.

autoEpochToTime(epoch)
Converts a long offset from Epoch value to a DBDateTime. This method uses expected date ranges to

infer whether the passed value is in milliseconds, microseconds, or nanoseconds. Thresholds used are TimeConstants.MICROTIME_THRESHOLD divided by 1000 for milliseconds, as-is for microseconds, and multiplied by 1000 for nanoseconds. The value is tested to see if its ABS exceeds the threshold. E.g. a value whose ABS is greater than 1000 * TimeConstants.MICROTIME_THRESHOLD will be treated as nanoseconds.

Parameters

epoch – (long) - The long Epoch offset value to convert.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) null, if the input is equal to QueryConstants.NULL_LONG, otherwise a DBDateTime based on the inferred conversion.

cappedTimeOffset(original, period, cap)
Returns a DBDateTime value based on a starting value and a DBPeriod to add to it,

but with a cap max value which is returned in case the starting value plus period exceeds the cap.

Parameters
  • original – (com.illumon.iris.db.tables.utils.DBDateTime) - The starting DBDateTime value.

  • period – (com.illumon.iris.db.tables.utils.DBPeriod) - The DBPeriod to add to dateTime.

  • cap – (com.illumon.iris.db.tables.utils.DBDateTime) - A DBDateTime value to use as the maximum return value.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) a null DBDateTime if either original or period are null; the starting DBDateTime plus the specified period, if the result is not too large for a DBDateTime and does not exceed the cap value; the cap value if this is less than offset plus period. Throws a DBDateTimeOverflowException if the resultant value is more than max long nanoseconds from Epoch.

convertDate(s)
Attempt to convert the given string to a LocalDate. This should not accept dates with times, as we want those

to be interpreted as DBDateTime values. The ideal date format is YYYY-MM-DD since it’s the least ambiguous, but this method also parses slash-delimited dates according to the system “date style”.

Parameters

s – (java.lang.String) - the date string to convert

Returns

java.time.LocalDate

convertDateQuiet(*args)
Attempt to convert the given string to a LocalDate. This should not accept dates with times, as we want those

to be interpreted as DBDateTime values. The ideal date format is YYYY-MM-DD since it’s the least ambiguous.

Overload 1
param s

(java.lang.String) - the date string to convert

return

(java.time.LocalDate) the LocalDate formatted using the default date style.

Overload 2
param s

(java.lang.String) - the date string

param dateStyle

(com.illumon.iris.db.tables.utils.DBTimeUtils.DateStyle) - indicates how to interpret slash-delimited dates

return

(java.time.LocalDate) the LocalDate

convertDateTime(s)

Converts a DateTime String from a few specific zoned formats to a DBDateTime

Parameters

s – (java.lang.String) - String to be converted, usually in the form yyyy-MM-ddThh:mm:ss and with optional sub-seconds after an optional decimal point, followed by a mandatory time zone character code

Returns

com.illumon.iris.db.tables.utils.DBDateTime

convertDateTimeQuiet(s)

Converts a DateTime String from a few specific zoned formats to a DBDateTime

Parameters

s – (java.lang.String) - String to be converted, usually in the form yyyy-MM-ddThh:mm:ss and with optional sub-seconds after an optional decimal point, followed by a mandatory time zone character code

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) A DBDateTime from the parsed String, or null if the format is not recognized or an exception occurs

convertExpression(formula)
Converts an expression, replacing DBDateTime and DBPeriod literals with references

to constant DBDateTime/DBPeriod instances.

Parameters

formula – (java.lang.String) - The formula to convert.

Returns

(com.illumon.iris.db.tables.utils.DBTimeUtils.Result) A DBTimeUtils.Result object, which includes the converted formula string, a string of instance variable declarations, and a map describing the names and types of these instance variables.

convertLocalTimeQuiet(s)

Converts a time String in the form hh:mm:ss[.nnnnnnnnn] to a LocalTime.

Parameters

s – (java.lang.String) - The String to convert.

Returns

(java.time.LocalTime) null if the String cannot be parsed, otherwise a LocalTime.

convertPeriod(s)

Converts a String into a DBPeriod object.

Parameters

s – (java.lang.String) - The String to convert in the form of numbertype, e.g. 1W for one week, and Tnumbertype for times, e.g. T1M for one minute.

Returns

com.illumon.iris.db.tables.utils.DBPeriod

convertPeriodQuiet(s)

Converts a String into a DBPeriod object.

Parameters

s – (java.lang.String) - The String to convert in the form of numbertype, e.g. 1W for one week, and Tnumbertype for times, e.g. T1M for one minute.

Returns

(com.illumon.iris.db.tables.utils.DBPeriod) null if the String cannot be parsed, otherwise a DBPeriod object.

convertTime(s)

Converts a String time to nanoseconds from Epoch. The format for the String is: hh:mm:ss[.nnnnnnnnn].

Parameters

s – (java.lang.String) - The String to be evaluated and converted.

Returns

(long) A long value representing an Epoch offset in nanoseconds. Throws RuntimeException if the String cannot be parsed.

convertTimeQuiet(s)

Converts a time String in the form hh:mm:ss[.nnnnnnnnn] to a long nanoseconds offset from Epoch.

Parameters

s – (java.lang.String) - The String to convert.

Returns

(long) QueryConstants.NULL_LONG if the String cannot be parsed, otherwise long nanoseconds offset from Epoch.

createFormatter(timeZoneName)

Create a DateTimeFormatter formatter with the specified time zone name using the standard yyyy-MM-dd format.

Parameters

timeZoneName – (java.lang.String) - the time zone name

Returns

(java.time.format.DateTimeFormatter) a formatter set for the specified time zone

currentDate(timeZone)

Returns a String of the current date in the specified DBTimeZone.

Parameters

timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to reference when evaluating the current date for “now”.

Returns

(java.lang.String) A String in format yyyy-MM-dd.

currentDateNy()
Provides a String representing the current date in the New York time zone or, if a custom DBTimeUtils.currentDateNyOverride

has been set, the date provided by that override.

Returns

(java.lang.String) A String in yyyy-MM-dd format.

currentTime()
Provides the current date/time, or, if a custom DBTimeUtils.timeProvider has been configured, provides the

current time according to the custom provider.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) A DBDateTime of the current date and time from the system or from the configured alternate time provider.

dateAtMidnight(dateTime, timeZone)
Returns a DBDateTime for the requested DBDateTime at midnight in the specified

time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - DBDateTime for which the new value at midnight should be calculated.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - DBTimeZone for which the new value at midnight should be calculated.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) A null DBDateTime if either input is null, otherwise a DBDateTime representing midnight for the date and time zone of the inputs.

dayOfMonth(dateTime, timeZone)

Returns an int value of the day of the month for a DBDateTime and specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the day of the month.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of the day of the month represented by the DBDateTime when interpreted in the specified time zone.

dayOfMonthNy(dateTime)

Returns an int value of the day of the month for a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the day of the month.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of the day of the month represented by the DBDateTime when interpreted in the New York time zone.

dayOfWeek(dateTime, timeZone)
Returns an int value of the day of the week for a DBDateTime in the specified time zone,

with 1 being Monday and 7 being Sunday.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the day of the week.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of the day of the week represented by the DBDateTime when interpreted in the specified time zone.

dayOfWeekNy(dateTime)
Returns an int value of the day of the week for a DBDateTime in the New York time zone,

with 1 being Monday and 7 being Sunday.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the day of the week.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of the day of the week represented by the DBDateTime when interpreted in the New York time zone.

dayOfYear(dateTime, timeZone)

Returns an int value of the day of the year (Julian date) for a DBDateTime in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the day of the year.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of the day of the year represented by the DBDateTime when interpreted in the specified time zone.

dayOfYearNy(dateTime)

Returns an int value of the day of the year (Julian date) for a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the day of the year.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of the day of the year represented by the DBDateTime when interpreted in the New York time zone.

diffDay(start, end)

Returns a double value of the number of days difference between two DBDateTime values.

Parameters
  • start – (com.illumon.iris.db.tables.utils.DBDateTime) - The first DBDateTime.

  • end – (com.illumon.iris.db.tables.utils.DBDateTime) - The second DBDateTime.

Returns

(double) QueryConstants.NULL_LONG if either input is null; a double value of the number of days obtained from the first DBDateTime value minus d2, if the intermediate value of nanoseconds difference between the two dates is not out of range for a long value; or throws a DBDateTimeOverflowException if the intermediate value would be more than min long or max long nanoseconds from Epoch. Note that the subtraction is done based the nanosecond offsets of the two dates from Epoch, so, if either date is before Epoch (negative offset), the result may be unexpected. If the second value is greater than the first value, the result will be negative.

diffNanos(d1, d2)

Returns the difference in nanoseconds between two DBDateTime values.

Parameters
  • d1 – (com.illumon.iris.db.tables.utils.DBDateTime) - The first DBDateTime.

  • d2 – (com.illumon.iris.db.tables.utils.DBDateTime) - The second DBDateTime.

Returns

(long) QueryConstants.NULL_LONG if either input is null; the long nanoseconds from Epoch value of the first DBDateTime minus d2, if the result is not out of range for a long value; or throws a DBDateTimeOverflowException if the resultant value would be more than min long or max long nanoseconds from Epoch. Note that the subtraction is done based the nanosecond offsets of the two dates from Epoch, so, if either date is before Epoch (negative offset), the result may be unexpected. If the second value is greater than the first value, the result will be negative.

diffYear(start, end)

Returns a double value of the number of 365 day units difference between two DBDateTime values.

Parameters
  • start – (com.illumon.iris.db.tables.utils.DBDateTime) - The first DBDateTime.

  • end – (com.illumon.iris.db.tables.utils.DBDateTime) - The second DBDateTime.

Returns

(double) QueryConstants.NULL_LONG if either input is null; a double value of the number of 365 day periods obtained from the first DBDateTime value minus d2, if the intermediate value of nanoseconds difference between the two dates is not out of range for a long value; or throws a DBTimeUtils.DBDateTimeOverflowException if the intermediate value would be more than min long or max long nanoseconds from Epoch. Note that the subtraction is done based the nanosecond offsets of the two dates from Epoch, so, if either date is before Epoch (negative offset), the result may be unexpected. If the second value is greater than the first value, the result will be negative.

expressionToNanos(formula)
Converts a String date/time to nanoseconds from Epoch or a nanoseconds period. Three patterns are supported:

yyyy-MM-ddThh:mm:ss[.nnnnnnnnn] TZ for date/time values

hh:mm:ss[.nnnnnnnnn] for time values Period Strings in the form of numbertype, e.g. 1W for one week, and Tnumbertype for times, e.g. T1M for one

minute

Parameters

formula – (java.lang.String) - The String to be evaluated and converted. Optionally, but preferred, enclosed in straight single ticks.

Returns

(long) A long value representing an Epoch offset in nanoseconds for a time or date/time, or a duration in nanoseconds for a period. Throws DBTimeUtils.DBDateTimeOverflowException if the resultant value would be longer than max long, or IllegalArgumentException if expression cannot be evaluated.

format(*args)

Returns a String date/time representation.

Overload 1
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime to format as a String.

param timeZone

(com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when formatting the String.

return

(java.lang.String) A null String if either input is null, otherwise a String formatted as yyyy-MM-ddThh:mm:ss.nnnnnnnnn TZ.

Overload 2
param nanos

(long) - The long number of nanoseconds offset from Epoch.

return

(java.lang.String) A String of varying format depending on the offset. For values greater than one day, the output will start with dddT

For values with fractional seconds, the output will be trailed by .nnnnnnnnn e.g. output may be dddThh:mm:ss.nnnnnnnnn or subsets of this.

formatDate(dateTime, timeZone)

Returns a String date representation of a DBDateTime interpreted for a specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime to format as a String.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when formatting the String.

Returns

(java.lang.String) A null String if either input is null, otherwise a String formatted as yyyy-MM-dd.

formatDateNy(dateTime)

Returns a String date representation of a DBDateTime interpreted for the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime to format as a String.

Returns

(java.lang.String) A null String if the input is null, otherwise a String formatted as yyyy-MM-dd.

formatNy(dateTime)

Returns a String date/time representation of a DBDateTime interpreted for the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime to format as a String.

Returns

(java.lang.String) A null String if the input is null, otherwise a String formatted as yyyy-MM-ddThh:mm:ss.nnnnnnnnn NY.

getExcelDateTime(*args)

Returns the Excel double time format representation of a DBDateTime.

Overload 1
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime to convert.

param timeZone

(com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

return

(double) 0.0 if either input is null, otherwise, a double value containing the Excel double format representation of a DBDateTime in the specified time zone.

Overload 2
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime to convert.

param timeZone

(java.util.TimeZone) - The TimeZone to use when interpreting the date/time.

return

(double) 0.0 if either input is null, otherwise, a double value containing the Excel double format representation of a DBDateTime in the specified time zone.

Overload 3
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime to convert.

return

(double) 0.0 if the input is null, otherwise, a double value containing the Excel double format representation of a DBDateTime in the New York time zone.

getFinestDefinedUnit(timeDef)

Returns a ChronoField indicating the level of precision in a String time value.

Parameters

timeDef – (java.lang.String) - The time String to evaluate.

Returns

(java.time.temporal.ChronoField) null if the time String cannot be parsed, otherwise a ChronoField for the finest units in the String (e.g. “10:00:00” would yield SecondOfMinute).

getPartitionFromTimestampMicros(dateTimeFormatter, timestampMicros)
Given a DateTimeFormatter and a timestamp in micros from epoch, return the date as a String in standard column-partition format of yyyy-MM-dd.

A timestamp of NULL_LONG means use the system current time.

Parameters
  • dateTimeFormatter – (java.time.format.DateTimeFormatter) - the date formatter

  • timestampMicros – (long) - the timestamp in micros

Returns

(java.lang.String) the formatted date

getPartitionFromTimestampMillis(dateTimeFormatter, timestampMillis)
Given a DateTimeFormatter and a timestamp in millis, return the date as a String in standard column-partition format of yyyy-MM-dd.

A timestamp of NULL_LONG means use the system current time.

Parameters
  • dateTimeFormatter – (java.time.format.DateTimeFormatter) - the date formatter

  • timestampMillis – (long) - the timestamp in millis

Returns

(java.lang.String) the formatted date

getPartitionFromTimestampNanos(dateTimeFormatter, timestampNanos)
Given a DateTimeFormatter and a timestamp in nanos from epoch, return the date as a String in standard column-partition format of yyyy-MM-dd.

A timestamp of NULL_LONG means use the system current time.

Parameters
  • dateTimeFormatter – (java.time.format.DateTimeFormatter) - the date formatter

  • timestampNanos – (long) - the timestamp in nanos

Returns

(java.lang.String) the formatted date

getPartitionFromTimestampSeconds(dateTimeFormatter, timestampSeconds)
Given a DateTimeFormatter and a timestamp in seconds from epoch, return the date as a String in standard column-partition format of yyyy-MM-dd.

A timestamp of NULL_LONG means use the system current time.

Parameters
  • dateTimeFormatter – (java.time.format.DateTimeFormatter) - the date formatter

  • timestampSeconds – (long) - the timestamp in seconds

Returns

(java.lang.String) the formatted date

getZonedDateTime(*args)

Converts a DBDateTime to a ZonedDateTime.

Overload 1
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The a DBDateTime to convert.

return

(java.time.ZonedDateTime) A ZonedDateTime using the default time zone for the session as indicated by DBTimeZone.TZ_DEFAULT.

Overload 2
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The a DBDateTime to convert.

param timeZone

(com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use for the conversion.

return

(java.time.ZonedDateTime) A ZonedDateTime using the specified time zone.

hourOfDay(dateTime, timeZone)
Returns an int value of the hour of the day for a DBDateTime in the specified time zone.

The hour is on a 24 hour clock (0 - 23).

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the hour of the day.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of the hour of the day represented by the DBDateTime when interpreted in the specified time zone.

hourOfDayNy(dateTime)
Returns an int value of the hour of the day for a DBDateTime in the New York time zone.

The hour is on a 24 hour clock (0 - 23).

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the hour of the day.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of the hour of the day represented by the DBDateTime when interpreted in the New York time zone.

isAfter(d1, d2)

Evaluates whether one DBDateTime value is later than a second DBDateTime value.

Parameters
  • d1 – (com.illumon.iris.db.tables.utils.DBDateTime) - The first DBDateTime value to compare.

  • d2 – (com.illumon.iris.db.tables.utils.DBDateTime) - The second DBDateTime value to compare.

Returns

(boolean) Boolean true if d1 is later than d2, false if either value is null, or if d2 is equal to or later than d1.

isBefore(d1, d2)

Evaluates whether one DBDateTime value is earlier than a second DBDateTime value.

Parameters
  • d1 – (com.illumon.iris.db.tables.utils.DBDateTime) - The first DBDateTime value to compare.

  • d2 – (com.illumon.iris.db.tables.utils.DBDateTime) - The second DBDateTime value to compare.

Returns

(boolean) Boolean true if d1 is earlier than d2, false if either value is null, or if d2 is equal to or earlier than d1.

lastBusinessDateNy(*args)
Provides a String representing the previous business date in the New York time zone using the NYSE calendar, or,

if a custom DBTimeUtils.lastBusinessDayNyOverride has been set, the date provided by that override.

Overload 1
return

(java.lang.String) A String in yyyy-MM-dd format.

Overload 2
param currentTimeMillis

(long) - The current date/time in milliseconds from Epoch to be used when determining the previous business date. Typically this is System.currentTimeMillis() and is passed in by calling the niladic variant of this method.

return

(java.lang.String) A String in yyyy-MM-dd format.

lowerBin(dateTime, intervalNanos)
Returns a DBDateTime value which is at the starting (lower) end of a time range defined

by the second parameter. E.g. lowerBin(someDateTime, 5*MINUTE) would return the date/time value for the start of the five minute window that contains someDateTime.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to evaluate the start of the containing window.

  • intervalNanos – (long) - The long size of the window in nanoseconds.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) Null if either input is null, otherwise a DBDateTime representing the start of the window.

microsOfMilli(dateTime, timeZone)
Returns the number of microseconds that have elapsed since the start of the millisecond represented by the

provided dateTime in the specified time zone. Nanoseconds are rounded, not dropped – ‘20:41:39.123456700’ has 457 micros, not 456.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the microseconds.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of microseconds since the top of the millisecond for the date/time represented by the DBDateTime when interpreted in the specified time zone.

microsOfMilliNy(dateTime)
Returns the number of microseconds that have elapsed since the start of the millisecond represented by the

provided dateTime in the New York time zone. Nanoseconds are rounded, not dropped – ‘20:41:39.123456700’ has 457 micros, not 456.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the microseconds.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of microseconds since the top of the millisecond for the date/time represented by the DBDateTime when interpreted in the New York time zone.

microsToNanos(micros)

Converts microseconds to nanoseconds.

Parameters

micros – (long) - The long value of microseconds to convert.

Returns

(long) A QueryConstants.NULL_LONG if the input is null. Throws a DBTimeUtils.DBDateTimeOverflowException if the resultant value would exceed the range that can be stored in a long. Otherwise, returns a long containing the equivalent number of nanoseconds for the input in microseconds.

microsToTime(micros)

Converts a value of microseconds from Epoch in the UTC time zone to a DBDateTime.

Parameters

micros – (long) - The long microseconds value to convert.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) QueryConstants.NULL_LONG if the input is null, otherwise, a DBDateTime representation of the input.

millis(dateTime)

Returns milliseconds since Epoch for a DBDateTime value.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which the milliseconds offset should be returned.

Returns

(long) A long value of milliseconds since Epoch, or a QueryConstants.NULL_LONG value if the DBDateTime is null.

millisOfDay(dateTime, timeZone)

Returns an int value of milliseconds since midnight for a DBDateTime in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the milliseconds since midnight.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of milliseconds since midnight for the date/time represented by the DBDateTime when interpreted in the specified time zone.

millisOfDayNy(dateTime)

Returns an int value of milliseconds since midnight for a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the milliseconds since midnight.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of milliseconds since midnight for the date/time represented by the DBDateTime when interpreted in the New York time zone.

millisOfSecond(dateTime, timeZone)
Returns an int value of milliseconds since the top of the second for a DBDateTime

in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the milliseconds.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of milliseconds since the top of the second for the date/time represented by the DBDateTime when interpreted in the specified time zone.

millisOfSecondNy(dateTime)
Returns an int value of milliseconds since the top of the second for a DBDateTime

in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the milliseconds.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of milliseconds since the top of the second for the date/time represented by the DBDateTime when interpreted in the New York time zone.

millisToDateAtMidnight(millis, timeZone)
Returns a DBDateTime representing midnight in a selected time zone on the date specified by the a number of

milliseconds from Epoch.

Parameters
  • millis – (long) - A long value of the number of milliseconds from Epoch for which the DBDateTime is to be calculated.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - DBTimeZone for which the new value at midnight should be calculated.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) A DBDateTime rounded down to midnight in the selected time zone for the specified number of milliseconds from Epoch.

millisToDateAtMidnightNy(millis)
Returns a DBDateTime representing midnight in New York time zone on the date specified by the a number of

milliseconds from Epoch.

Parameters

millis – (long) - A long value of the number of milliseconds from Epoch for which the DBDateTime is to be calculated.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) A DBDateTime rounded down to midnight in the New York time zone for the specified number of milliseconds from Epoch.

millisToNanos(millis)

Converts milliseconds to nanoseconds.

Parameters

millis – (long) - The long milliseconds value to convert.

Returns

(long) QueryConstants.NULL_LONG if the input is equal to QueryConstants.NULL_LONG. Throws DBTimeUtils.DBDateTimeOverflowException if the input is too large for conversion. Otherwise returns a long of the equivalent number of nanoseconds to the input.

millisToTime(millis)

Converts a value of milliseconds from Epoch in the UTC time zone to a DBDateTime.

Parameters

millis – (long) - The long milliseconds value to convert.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) QueryConstants.NULL_LONG if the input is null, otherwise, a DBDateTime representation of the input.

minus(*args)

Subtracts one time from another.

Overload 1
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The starting DBDateTime value.

param nanos

(long) - The long number of nanoseconds to subtract from dateTime.

return

(com.illumon.iris.db.tables.utils.DBDateTime) a null DBDateTime if either input is null; the starting DBDateTime minus the specified number of nanoseconds, if the result is not too negative for a DBDateTime; or throws a DBDateTimeOverflowException if the resultant value is more than min long nanoseconds from Epoch.

Overload 2
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The starting DBDateTime value.

param period

(com.illumon.iris.db.tables.utils.DBPeriod) - The DBPeriod to subtract from dateTime.

return

(com.illumon.iris.db.tables.utils.DBDateTime) a null DBDateTime if either input is null; the starting DBDateTime minus the specified period, if the result is not too negative for a DBDateTime; or throws a DBDateTimeOverflowException if the resultant value is more than min long nanoseconds from Epoch.

Overload 3
param d1

(com.illumon.iris.db.tables.utils.DBDateTime) - The first DBDateTime.

param d2

(com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime to subtract from d1.

return

(long) QueryConstants.NULL_LONG if either input is null; the long nanoseconds from Epoch value of the first DBDateTime minus d2, if the result is not out of range for a long value; or throws a DBDateTimeOverflowException if the resultant value would be more than min long or max long nanoseconds from Epoch. Note that the subtraction is done based the nanosecond offsets of the two dates from Epoch, so, if either date is before Epoch (negative offset), the result may be unexpected.

minuteOfDay(dateTime, timeZone)

Returns an int value of minutes since midnight for a DBDateTime in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the minutes.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of minutes since midnight for the date/time represented by the DBDateTime when interpreted in the specified time zone.

minuteOfDayNy(dateTime)

Returns an int value of minutes since midnight for a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the milliseconds since midnight.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of minutes since midnight for the date/time represented by the DBDateTime when interpreted in the New York time zone.

minuteOfHour(dateTime, timeZone)

Returns an int value of minutes since the top of the hour for a DBDateTime in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the minutes.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of minutes since the top of the hour for the date/time represented by the DBDateTime when interpreted in the specified time zone.

minuteOfHourNy(dateTime)

Returns an int value of minutes since the top of the hour for a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the minutes.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of minutes since the top of the hour for the date/time represented by the DBDateTime when interpreted in the New York time zone.

monthOfYear(dateTime, timeZone)

Returns an int value for the month of a DBDateTime in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the month.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of the month for the date/time represented by the DBDateTime when interpreted in the specified time zone. January is 1, February is 2, etc.

monthOfYearNy(dateTime)

Returns an int value for the month of a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the month.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of the month for the date/time represented by the DBDateTime when interpreted in the New York time zone.

nanos(dateTime)

Returns nanoseconds since Epoch for a DBDateTime value.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which the nanoseconds offset should be returned.

Returns

(long) A long value of nanoseconds since Epoch, or a NULL_LONG value if the DBDateTime is null.

nanosOfDay(dateTime, timeZone)

Returns a long value of nanoseconds since midnight for a DBDateTime in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the nanoseconds since midnight.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(long) A QueryConstants.NULL_LONG if either input is null, otherwise, a long value of nanoseconds since midnight for the date/time represented by the DBDateTime when interpreted in the specified time zone.

nanosOfDayNy(dateTime)

Returns a long value of nanoseconds since midnight for a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the nanoseconds since midnight.

Returns

(long) A QueryConstants.NULL_LONG if the input is null, otherwise, a long value of nanoseconds since midnight for the date/time represented by the DBDateTime when interpreted in the New York time zone.

nanosOfSecond(dateTime, timeZone)
Returns a long value of nanoseconds since the top of the second for a DBDateTime

in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the nanoseconds.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(long) A QueryConstants.NULL_LONG if either input is null, otherwise, a long value of nanoseconds since the top of the second for the date/time represented by the DBDateTime when interpreted in the specified time zone.

nanosOfSecondNy(dateTime)
Returns a long value of nanoseconds since the top of the second for a DBDateTime

in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the nanoseconds.

Returns

(long) A QueryConstants.NULL_LONG if the input is null, otherwise, a long value of nanoseconds since the top of the second for the date/time represented by the DBDateTime when interpreted in the New York time zone.

nanosToMicros(nanos)

Converts nanoseconds to microseconds.

Parameters

nanos – (long) - The long value of nanoseconds to convert.

Returns

(long) A QueryConstants.NULL_LONG if the input is null. Otherwise, returns a long containing the equivalent number of microseconds for the input in nanoseconds.

nanosToMillis(nanos)

Converts nanoseconds to milliseconds.

Parameters

nanos – (long) - The long value of nanoseconds to convert.

Returns

(long) A QueryConstants.NULL_LONG if the input is null. Otherwise, returns a long containing the equivalent number of milliseconds for the input in nanoseconds.

nanosToTime(nanos)

Converts a value of nanoseconds from Epoch to a DBDateTime.

Parameters

nanos – (long) - The long nanoseconds since Epoch value to convert.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) A DBDateTime for nanos, or null if nanos is equal to NULL_LONG.

overrideLastBusinessDateNyFromCurrentDateNy()
Sets the DBTimeUtils.lastBusinessDayNyOverride to the previous business day from a currently set

DBTimeUtils.currentDateNyOverride value. If DBTimeUtils.currentDateNyOverride has not been set, this method has no effect.

plus(*args)

Adds one time from another.

Overload 1
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The starting DBDateTime value.

param nanos

(long) - The long number of nanoseconds to add to dateTime.

return

(com.illumon.iris.db.tables.utils.DBDateTime) a null DBDateTime if either input is null; the starting DBDateTime plus the specified number of nanoseconds, if the result is not too large for a DBDateTime; or throws a DBDateTimeOverflowException if the resultant value is more than max long nanoseconds from Epoch.

Overload 2
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The starting DBDateTime value.

param period

(com.illumon.iris.db.tables.utils.DBPeriod) - The DBPeriod to add to dateTime.

return

(com.illumon.iris.db.tables.utils.DBDateTime) a null DBDateTime if either input is null; the starting DBDateTime plus the specified period, if the result is not too large for a DBDateTime; or throws a DBDateTimeOverflowException if the resultant value is more than max long nanoseconds from Epoch.

secondOfDay(dateTime, timeZone)

Returns an int value of seconds since midnight for a DBDateTime in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the seconds.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of seconds since midnight for the date/time represented by the DBDateTime when interpreted in the specified time zone.

secondOfDayNy(dateTime)

Returns an int value of seconds since midnight for a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the seconds.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of seconds since midnight for the date/time represented by the DBDateTime when interpreted in the New York time zone.

secondOfMinute(dateTime, timeZone)

Returns an int value of seconds since the top of the minute for a DBDateTime in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the seconds.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of seconds since the top of the minute for the date/time represented by the DBDateTime when interpreted in the specified time zone.

secondOfMinuteNy(dateTime)

Returns an int value of seconds since the top of the minute for a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the seconds.

Returns

(int) A QueryConstants.NULL_INT if the input is null, otherwise, an int value of seconds since the top of the minute for the date/time represented by the DBDateTime when interpreted in the New York time zone.

secondsToNanos(seconds)

Converts seconds to nanoseconds.

Parameters

seconds – (long) - The long value of seconds to convert.

Returns

(long) A QueryConstants.NULL_LONG if the input is null. Throws a DBTimeUtils.DBDateTimeOverflowException if the resultant value would exceed the range that can be stored in a long. Otherwise, returns a long containing the equivalent number of nanoseconds for the input in seconds.

secondsToTime(seconds)

Converts a value of seconds from Epoch in the UTC time zone to a DBDateTime.

Parameters

seconds – (long) - The long seconds value to convert.

Returns

(com.illumon.iris.db.tables.utils.DBDateTime) QueryConstants.NULL_LONG if the input is null, otherwise, a DBDateTime representation of the input.

toDateTime(zonedDateTime)

Converts a ZonedDateTime to a DBDateTime.

Parameters

zonedDateTime – (java.time.ZonedDateTime) - The a ZonedDateTime to convert.

Returns

com.illumon.iris.db.tables.utils.DBDateTime

upperBin(*args)
Returns a DBDateTime value, which is at the ending (upper) end of a time range defined

by the interval nanoseconds. For example, a 5*MINUTE intervalNanos value would return the date/time value for the end of the five minute window that contains the input date time.

Overload 1
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to evaluate the end of the containing window.

param intervalNanos

(long) - The size of the window in nanoseconds.

return

(com.illumon.iris.db.tables.utils.DBDateTime) Null if either input is null, otherwise a DBDateTime representing the end of the window.

Overload 2
param dateTime

(com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to evaluate the end of the containing window.

param intervalNanos

(long) - The size of the window in nanoseconds.

param offset

(long) - The window start offset in nanoseconds. For example, a value of MINUTE would offset all windows by one minute.

return

(com.illumon.iris.db.tables.utils.DBDateTime) Null if either input is null, otherwise a DBDateTime representing the end of the window.

year(dateTime, timeZone)

Returns an int value of the year for a DBDateTime in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the year.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of the year for the date/time represented by the DBDateTime when interpreted in the specified time zone.

yearNy(dateTime)

Returns an int value of the year for a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the year.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of the year for the date/time represented by the DBDateTime when interpreted in the New York time zone.

yearOfCentury(dateTime, timeZone)

Returns an int value of the two-digit year for a DBDateTime in the specified time zone.

Parameters
  • dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the year.

  • timeZone – (com.illumon.iris.db.tables.utils.DBTimeZone) - The DBTimeZone to use when interpreting the date/time.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of the two-digit year for the date/time represented by the DBDateTime when interpreted in the specified time zone.

yearOfCenturyNy(dateTime)

Returns an int value of the two-digit year for a DBDateTime in the New York time zone.

Parameters

dateTime – (com.illumon.iris.db.tables.utils.DBDateTime) - The DBDateTime for which to find the year.

Returns

(int) A QueryConstants.NULL_INT if either input is null, otherwise, an int value of the two-digit year for the date/time represented by the DBDateTime when interpreted in the New York time zone.