to_date
to_date
converts a Java date-time to a datetime.date
.
danger
to_date
should never be used in query strings.
Syntax
to_date(dt: Union[None, LocalDate, ZonedDateTime]) -> datetime.date
Parameters
Parameter | Type | Description |
---|---|---|
dt | Union[None, LocalDate, ZonedDateTime] | A Java date-time to convert to a |
Returns
Returns a datetime.date
.
Examples
from deephaven.time import dh_today, to_j_local_date, to_date, to_j_zdt
# create a LocalDate
date_str = dh_today()
local_date = to_j_local_date(date_str)
# create a ZonedDateTime
date_str_tz = date_str + " ET"
zdt = to_j_zdt(date_str_tz)
# convert LocalDate and ZonedDateTime to `datetime.date`
date_local = to_date(local_date)
date_zoned = to_date(zdt)
print(date_local)
print(date_zoned)