DateTime Methods

(DBTimeUtils Class)

Methods in the DBTimeUtils class can be used to create, manipulate, and gather information about DBDateTimes, time/durations, and Periods. All of the functions handle null values.

These methods are automatically imported by defa480 Holdings Ltd.ult when using Groovy as your scripting language. When using Python, you'll need to include the from deephaven import * statement in the query to import the DBTimeUtils class. For example:

from deephaven import *
print dbtu.HOUR

Method

Description

long millis(DBDateTime dateTime)

the datetime in milliseconds

long nanos(DBDateTime dateTime)

the datetime in nanoseconds

boolean isBefore(DBDateTime d1, DBDateTime d2)

tests whether d1<d2 (note: you can just use d1<d2 in the query language)

boolean isAfter(DBDateTime d1, DBDateTime d2)

tests whether d1>d2 (note: you can just use d1>d2 in the query language)

DBDateTime plus(DBDateTime dateTime, long nanos)

returns the sum of a datetime and a time/duration (note: you can use dateTime+nanos in the query language)

DBDateTime plus(DBDateTime dateTime, DBPeriod period)

returns the sum of a datetime and a period (note: you can use dateTime+period in the query language)

long minus(DBDateTime d1, DBDateTime d2)

returns the difference in nanos between two datetimes (note: you can use d1-d2 in the query language)

long minus(DBDateTime d1, long nanos)

returns the difference in nanos between two datetimes (note: you can use d1-d2 in the query language)

long diff(DBDateTime d1, DBDateTime d2)

returns the difference in nanos from d1 to d2 (note: you can use d2-d1 in the query language)

DBDateTime dateAtMidnight(DBDateTime dateTime, DBTimeZone timeZone)

returns a DBDateTime representing that date at midnight

String format(DBDateTime dateTime, DBTimeZone timeZone)

returns a formatted String (date and time) for a DBDateTime

String formatDate(DBDateTime dateTime, DBTimeZone timeZone)

returns a formatted String (date only) for a DBDateTime

String format(long nanos)

returns a formatted String for this datetime passed in as nanos

int dayOfMonth(DBDateTime dateTime, DBTimeZone timeZone)

the day of the month for a datetime

int dayOfWeek(DBDateTime dateTime, DBTimeZone timeZone)

the day of the week for a datetime

int dayOfYear(DBDateTime dateTime, DBTimeZone timeZone)

the day of the year for a datetime

int hourOfDay(DBDateTime dateTime, DBTimeZone timeZone)

the hour of the day for a datetime

int millisOfDay(DBDateTime dateTime, DBTimeZone timeZone)

the milliseconds of the day for a datetime

int millisOfSecond(DBDateTime dateTime, DBTimeZone timeZone)

the milliseconds of the second for a datetime

long nanosOfDay(DBDateTime dateTime, DBTimeZone timeZone)

the nanos of the day for a datetime

long nanosOfSecond(DBDateTime dateTime, DBTimeZone timeZone)

the nanos of the second for a datetime

int minuteOfDay(DBDateTime dateTime, DBTimeZone timeZone)

the minute of the day for a datetime

int minuteOfHour(DBDateTime dateTime, DBTimeZone timeZone)

the minute of the hour for a datetime

int monthOfYear(DBDateTime dateTime, DBTimeZone timeZone)

the month of the year for a datetime

int secondOfDay(DBDateTime dateTime, DBTimeZone timeZone)

the second of the day for a datetime

int secondOfMinute(DBDateTime dateTime, DBTimeZone timeZone)

the second of the minute for a datetime

int year(DBDateTime dateTime, DBTimeZone timeZone)

the year of a datetime

int yearOfCentury(DBDateTime dateTime, DBTimeZone timeZone)

the year of the century for a datetime

final long millisToNanos(long millis)

converts milliseconds to nanoseconds

final long nanosToMillis(long nanos)

converts nanoseconds to milliseconds

final DBDateTime millisToTime(long millis)

converts milliseconds into a DBDateTime

final DBDateTime nanosToTime(long nanos)

converts nanoseconds into a DBDateTime

DBDateTime lowerBin(DBDateTime dateTime, long intervalNanos)

bins the dateTimes according to the intervalNanos (returns lower bin)

DBDateTime upperBin(DBDateTime dateTime, long intervalNanos)

bins the dateTimes according to the intervalNanos (returns upper bin)

DBDateTime convertDateTime(String s)

parses a String into a DBDateTime (throws an exception if invalid)

long convertTime(String s)

parses a String into a time/duration (throws an exception if invalid)

DBPeriod convertPeriod(String s)

parses a String into a DBPeriod (throws an exception if invalid)

DBDateTime convertDateTimeQuiet(String s)

parses a String into a DBDateTime (returns null if invalid)

long convertTimeQuiet(String s)

parses a String into a time/duration (returns null if invalid)

DBPeriod convertPeriodQuiet(String s)

parses a String into a DBPeriod (returns null if invalid)


Last Updated: 16 February 2021 18:07 -04:00 UTC    Deephaven v.1.20200928  (See other versions)

Deephaven Documentation     Copyright 2016-2020  Deephaven Data Labs, LLC     All Rights Reserved