Class DataTypeUtils

java.lang.Object
com.clickhouse.client.api.DataTypeUtils

public class DataTypeUtils extends Object
  • Field Details

    • DATETIME_FORMATTER

      public static DateTimeFormatter DATETIME_FORMATTER
      Formatter for the DateTime type.
    • DATE_FORMATTER

      public static DateTimeFormatter DATE_FORMATTER
      Formatter for the Date type.
    • DATETIME_WITH_NANOS_FORMATTER

      public static DateTimeFormatter DATETIME_WITH_NANOS_FORMATTER
      Formatter for the DateTime type with nanoseconds.
  • Constructor Details

    • DataTypeUtils

      public DataTypeUtils()
  • Method Details

    • formatInstant

      public static String formatInstant(Instant instant)
      Formats an Instant object 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 - if instant is null
    • formatInstant

      public static String formatInstant(Instant instant, ClickHouseDataType dataTypeHint)
      Formats an Instant object for use in SQL statements or as query parameter. This method uses the dataTypeHint parameter to find the best suitable format for the instant.
      Parameters:
      instant - the Java object to format
      dataTypeHint - the ClickHouse data type instant should be used for
      Returns:
      a suitable String representation of instant
      Throws:
      NullPointerException - if instant is null
    • formatInstant

      public static String formatInstant(Instant instant, ClickHouseDataType dataTypeHint, ZoneId timeZone)
      Formats an Instant object for use in SQL statements or as query parameter. This method uses the dataTypeHint parameter to find the best suitable format for the instant. For some formatting operations, providing a timeZone is mandatory, e.g. for ClickHouseDataType.Date.
      Parameters:
      instant - the Java object to format
      dataTypeHint - the ClickHouse data type object should be used for
      timeZone - 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 for null objects
      Throws:
      NullPointerException - if instant is null
    • instantFromTime64Integer

      public static Instant instantFromTime64Integer(int precision, long value)