date-time
A date-time
value indicates a specific instance in time. In Deephaven, a date-time
is typically represented by one of two data types:
These data types are used by Deephaven tables to represent moments in time. They are also used in the Python API. Both will be covered in this reference guide.
Instant
A java.time.Instant
represents a single instantaneous point in time, given in the UTC
time zone. Printing an instance of an instant always ends in the letter Z
, which is shorthand for UTC
.
ZonedDateTime
A java.time.ZonedDateTime
represents a single instantaneous point in time, given in the specified time zone. Printing an instance of a zoned date-time always ends in the specified time zone. For instance, for the ET
(US Eastern Time) time zone, a ZonedDateTime
ends in [America/New_York]
.
Syntax
'YYYY-MM-DDThh:mm:ss.ddddddddd TZ'
YYYY
- the yearMM
- the monthDD
- the dayT
- the separator between the date and timehh
- the hour of the daymm
- the minute of the hourss
- the second of the minuteddddddddd
- the fraction of a secondTZ
- the time zone
Example
The following example uses to_j_instant
and to_j_zdt
to convert two dates into Instant
s and ZonedDateTime
s. The results are then printed.
from deephaven.time import to_j_instant, to_j_zdt
instant_1 = to_j_instant("2021-07-04T08:00:00 PT")
zdt_1 = to_j_zdt("2021-07-04T08:00:00 PT")
zdt_2 = to_j_zdt("2021-09-06T12:30:00 GMT")
instant_2 = to_j_instant("2021-09-06T12:30:00 GMT")
print(instant_1)
print(zdt_1)
print(instant_2)
print(zdt_2)
- Log