Package com.clickhouse.client.api
Class DataTypeUtils
java.lang.Object
com.clickhouse.client.api.DataTypeUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic DateTimeFormatterFormatter for the Date type.static DateTimeFormatterFormatter for the DateTime type.static DateTimeFormatterFormatter for the DateTime type with nanoseconds. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatInstant(Instant instant) Formats anInstantobject for use in SQL statements or as query parameter.static StringformatInstant(Instant instant, ClickHouseDataType dataTypeHint) Formats anInstantobject for use in SQL statements or as query parameter.static StringformatInstant(Instant instant, ClickHouseDataType dataTypeHint, ZoneId timeZone) Formats anInstantobject for use in SQL statements or as query parameter.static InstantinstantFromTime64Integer(int precision, long value)
-
Field Details
-
DATETIME_FORMATTER
Formatter for the DateTime type. -
DATE_FORMATTER
Formatter for the Date type. -
DATETIME_WITH_NANOS_FORMATTER
Formatter for the DateTime type with nanoseconds.
-
-
Constructor Details
-
DataTypeUtils
public DataTypeUtils()
-
-
Method Details
-
formatInstant
Formats anInstantobject for use in SQL statements or as query parameter.- Parameters:
instant- the Java object to format- Returns:
- a suitable String representation of
instant - Throws:
NullPointerException- ifinstantis null
-
formatInstant
Formats anInstantobject for use in SQL statements or as query parameter. This method uses thedataTypeHintparameter to find the best suitable format for the instant.- Parameters:
instant- the Java object to formatdataTypeHint- the ClickHouse data typeinstantshould be used for- Returns:
- a suitable String representation of
instant - Throws:
NullPointerException- ifinstantis null
-
formatInstant
public static String formatInstant(Instant instant, ClickHouseDataType dataTypeHint, ZoneId timeZone) Formats anInstantobject for use in SQL statements or as query parameter. This method uses thedataTypeHintparameter to find the best suitable format for the instant. For some formatting operations, providing atimeZoneis mandatory, e.g. forClickHouseDataType.Date.- Parameters:
instant- the Java object to formatdataTypeHint- the ClickHouse data typeobjectshould be used fortimeZone- the time zone to be used when formatting the instant for use in non-time-zone-based ClickHouse data types- Returns:
- a suitable String representation of
object, or the empty String fornullobjects - Throws:
NullPointerException- ifinstantis null
-
instantFromTime64Integer
-