Package com.illumon.iris.db.tables.utils
Class DBDateTime
java.lang.Object
com.illumon.iris.db.tables.utils.DBDateTime
- All Implemented Interfaces:
DatetimeFilterData.MillisProvider
,Externalizable
,Serializable
,Comparable<DBDateTime>
public final class DBDateTime extends Object implements Comparable<DBDateTime>, Externalizable, DatetimeFilterData.MillisProvider
An object representing a timpoint in Deephaven.
A DBDateTime represents a zone-less, precise timepoint without respect to timezones. The
instant is stored as a signed 64-bit long, representing nanoseconds since the epoch (January 1, 1970, 00:00:00 GMT). This
provides a range from 1677-09-21T00:12:43.146-775807 UTC to 2262-04-11T23:47:16.854775807 UTC. The minimum long
value is reserved for QueryConstants.NULL_LONG
and therefore is not permitted as a valid DBDateTime.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description DBDateTime()
Create a new DBDatetime initialized to the epoch.DBDateTime(long nanos)
Create a new DBDateTime initialized to the provided nanoseconds since the epoch. -
Method Summary
Modifier and Type Method Description int
compareTo(DBDateTime dateTime)
boolean
equals(Object that)
Date
getDate()
Deprecated.usetoZonedDateTime()
instead.Instant
getInstant()
Convert this DBDateTime to a Java Instant.org.joda.time.DateTime
getJodaDateTime()
Deprecated.usetoZonedDateTime()
insteadorg.joda.time.DateTime
getJodaDateTime(DBTimeZone timeZone)
Deprecated.usetoZonedDateTime(ZoneId)
insteadlong
getMicros()
Get this time represented as microseconds since the epochlong
getMillis()
Get this time represented as milliseconds since the epochlong
getNanos()
Get this time represented as nanoseconds since the epochlong
getNanosPartial()
Get nanoseconds-of-milliseconds; this number will always be between 0 and 999,999int
hashCode()
static DBDateTime
now()
Create a new DBDatetime initialized to the current time.void
readExternal(ObjectInput in)
String
toDateString()
Get the date represented by this DBDateTime in the defaultDBTimeZone
.String
toDateString(DBTimeZone timeZone)
Get the date represented by this DBDateTime in the givenDBTimeZone
.String
toDateString(String zoneId)
Get the date represented by this DBDateTime in the time zone specified byzoneId
inISO
date format.String
toDateString(ZoneId timeZone)
Get the date represented by this DBDateTime in the given javaZoneId
inISO
date format.String
toDateString(org.joda.time.DateTimeZone timeZone)
Get the date represented by this DBDateTime in the given JodaDateTimeZone
in ISO date format yyyy-mm.LocalDate
toLocalDate()
LocalDate
toLocalDate(DBTimeZone zone)
Get aLocalDate
representing the date of thisDBDateTime
at the specified time zone.LocalDate
toLocalDate(String zone)
Get aLocalDate
representing the date of thisDBDateTime
at the specified time zone.LocalDate
toLocalDate(ZoneId zone)
Get aLocalDate
representing the date of thisDBDateTime
at the specified time zone.LocalTime
toLocalTime()
LocalTime
toLocalTime(DBTimeZone zone)
Get aLocalTime
representing the time of day of thisDBDateTime
at the specified time zone.LocalTime
toLocalTime(String zone)
Get aLocalTime
representing the time of day of thisDBDateTime
at the specified time zone.LocalTime
toLocalTime(ZoneId zone)
Get aLocalTime
representing the time of day of thisDBDateTime
at the specified time zone.String
toString()
String
toString(DBTimeZone timeZone)
Convert this DBDateTime into a String using the providedDBTimeZone
.ZonedDateTime
toZonedDateTime()
ZonedDateTime
toZonedDateTime(DBTimeZone zone)
Get aZonedDateTime
version of thisDBDateTime
at the specified time zone.ZonedDateTime
toZonedDateTime(String zone)
Get aZonedDateTime
version of thisDBDateTime
at the specified time zone.ZonedDateTime
toZonedDateTime(ZoneId zone)
Get aZonedDateTime
version of thisDBDateTime
at the specified time zone.void
writeExternal(ObjectOutput out)
-
Constructor Details
-
DBDateTime
public DBDateTime()Create a new DBDatetime initialized to the epoch. -
DBDateTime
public DBDateTime(long nanos)Create a new DBDateTime initialized to the provided nanoseconds since the epoch.- Parameters:
nanos
- the number of nanoseconds since the epoch
-
-
Method Details
-
now
Create a new DBDatetime initialized to the current time.The precision of DBDateTime is nanoseconds, but the resolution of the now method is currently microseconds.
- Returns:
- a new DBDateTime initialized to the current time.
-
getNanos
public long getNanos()Get this time represented as nanoseconds since the epoch- Returns:
- the number of nanoseconds since the epoch
-
getMicros
public long getMicros()Get this time represented as microseconds since the epoch- Returns:
- the number of microseconds since the epoch
-
getMillis
public long getMillis()Get this time represented as milliseconds since the epoch- Specified by:
getMillis
in interfaceDatetimeFilterData.MillisProvider
- Returns:
- the number of milliseconds since the epoch
-
getNanosPartial
public long getNanosPartial()Get nanoseconds-of-milliseconds; this number will always be between 0 and 999,999- Returns:
- the number of nanoseconds after the nearest millisecond.
-
getJodaDateTime
Deprecated.usetoZonedDateTime()
insteadConvert this DBDateTime to a Joda DateTime. This DBDateTime will be truncated to milliseconds.- Returns:
- a Joda DateTime representing this DBDateTime
-
getJodaDateTime
Deprecated.usetoZonedDateTime(ZoneId)
insteadConvert this DBDateTime to a Joda DateTime. This DBDateTime will be truncated to milliseconds.- Parameters:
timeZone
- the timezone for the created Joda DateTime- Returns:
- a Joda DateTime representing this DBDateTime
-
toZonedDateTime
- Returns:
- a
ZonedDateTime
-
toZonedDateTime
Get aZonedDateTime
version of thisDBDateTime
at the specified time zone.- Returns:
- a
ZonedDateTime
-
toZonedDateTime
Get aZonedDateTime
version of thisDBDateTime
at the specified time zone.- Returns:
- a
ZonedDateTime
-
toZonedDateTime
Get aZonedDateTime
version of thisDBDateTime
at the specified time zone.- Returns:
- a
ZonedDateTime
-
toLocalDate
- Returns:
- the
LocalDate
-
toLocalDate
Get aLocalDate
representing the date of thisDBDateTime
at the specified time zone.- Returns:
- the
LocalDate
-
toLocalDate
Get aLocalDate
representing the date of thisDBDateTime
at the specified time zone.- Returns:
- the
LocalDate
-
toLocalDate
Get aLocalDate
representing the date of thisDBDateTime
at the specified time zone.- Returns:
- the
LocalDate
-
toLocalTime
- Returns:
- the
LocalTime
-
toLocalTime
Get aLocalTime
representing the time of day of thisDBDateTime
at the specified time zone.- Returns:
- the
LocalTime
-
toLocalTime
Get aLocalTime
representing the time of day of thisDBDateTime
at the specified time zone.- Returns:
- the
LocalTime
-
toLocalTime
Get aLocalTime
representing the time of day of thisDBDateTime
at the specified time zone.- Returns:
- the
LocalTime
-
getDate
Deprecated.usetoZonedDateTime()
instead.Convert this DBDateTime to a Java Date. This DBDateTime will be truncated to milliseconds.- Returns:
- a Java Date representing this DBDateTime
-
getInstant
Convert this DBDateTime to a Java Instant.- Returns:
- a Java Instant representing this DBDateTime
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<DBDateTime>
-
toString
-
toString
Convert this DBDateTime into a String using the providedDBTimeZone
.The date will be formatted as
yyyy-MM-DDThh:mm:ss.SSSSSSSSS TZ
, for example2020-05-27T13:37:57.780853000 NY
or2020-05-27T17:37:42.763641000 UTC
.- Parameters:
timeZone
- the timezone for formatting the string- Returns:
- a String representation of this DBDateTime
-
toDateString
Get the date represented by this DBDateTime in the defaultDBTimeZone
.- Returns:
- The date (yyyy-MM-dd) represented by this
DBDateTime
in the defaultDBTimeZone
.
-
toDateString
Get the date represented by this DBDateTime in the givenDBTimeZone
.- Parameters:
timeZone
- a DBTimeZone- Returns:
- The date (yyyy-MM-dd) represented by this
DBDateTime
in the given timeZone.
-
toDateString
Get the date represented by this DBDateTime in the given JodaDateTimeZone
in ISO date format yyyy-mm.- Parameters:
timeZone
- A joda DateTimeZone- Returns:
- The date (yyyy-MM-dd) represented by this
DBDateTime
in the giventimeZone
-
toDateString
Get the date represented by this DBDateTime in the time zone specified byzoneId
inISO
date format.- Parameters:
zoneId
- A java time zone ID string- Returns:
- The date (yyyy-MM-dd) represented by this
DBDateTime
in time zone represented by the givenzoneId
-
toDateString
Get the date represented by this DBDateTime in the given javaZoneId
inISO
date format.- Parameters:
timeZone
- A javatime zone ID
.- Returns:
- The date (yyyy-MM-dd) represented by this
DBDateTime
in the giventimeZone
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-