Skip to main content
Version: Python

to_datetime

to_datetime converts a Java date-time to a datetime.datetime.

danger

to_datetime should never be used in query strings.

Syntax

to_datetime(dt: Union[None, Instant, ZonedDateTime]) -> datetime.datetime

Parameters

ParameterTypeDescription
dtUnion[None, Instant, ZonedDateTime]

A Java date-time to convert to a datetime.datetime. If None is provided, None is returned.

Returns

Returns a datetime.datetime.

Examples

from deephaven.time import dh_now, to_datetime, to_j_zdt

java_date = dh_now()

zdt = to_j_zdt("2024-03-22T11:11:11.23142 UTC")

datetime = to_datetime(java_date)

datetime_from_zdt = to_datetime(zdt)

print(datetime)
print(datetime_from_zdt)