gpt4 book ai didi

io.debezium.time.ZonedTimestamp类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 18:51:31 30 4
gpt4 key购买 nike

本文整理了Java中io.debezium.time.ZonedTimestamp类的一些代码示例,展示了ZonedTimestamp类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedTimestamp类的具体详情如下:
包路径:io.debezium.time.ZonedTimestamp
类名称:ZonedTimestamp

ZonedTimestamp介绍

[英]A utility for converting various Java time representations into the SchemaBuilder#string() representation of the time and date in a particular time zone, and for defining a Kafka Connect Schema for zoned timestamp values.

The ISO date-time format includes the date, time (including fractional parts), and offset from UTC, such as '2011-12-03T10:15:30+01:00'.
[中]用于将各种Java时间表示转换为特定时区中时间和日期的SchemaBuilder#string()表示,以及为分区时间戳值定义Kafka Connect模式的实用程序。
ISO日期时间格式包括日期、时间(包括小数部分)和与UTC的偏移量,例如“2011-12-03T10:15:30+01:00”。

代码示例

代码示例来源:origin: debezium/debezium

/**
 * Returns a Schema for a {@link ZonedTimestamp} but with all other default Schema settings.
 * 
 * @return the schema
 * @see #builder()
 */
public static Schema schema() {
  return builder().build();
}

代码示例来源:origin: debezium/debezium

/**
 * Get the ISO 8601 formatted representation of the given {@link java.util.Date} or one of its JDBC subclasses, using
 * the supplied timezone information.
 * 
 * @param timestamp the timestamp value
 * @param zoneId the timezone identifier or offset where the timestamp is defined
 * @param adjuster the optional component that adjusts the local date value before obtaining the epoch day; may be null if no
 * adjustment is necessary
 * @return the ISO 8601 formatted string
 */
public static String toIsoString(java.util.Date timestamp, ZoneId zoneId, TemporalAdjuster adjuster) {
  if (timestamp instanceof java.sql.Timestamp) {
    return toIsoString((java.sql.Timestamp) timestamp, zoneId, adjuster);
  }
  if (timestamp instanceof java.sql.Date) {
    return toIsoString((java.sql.Date) timestamp, zoneId, adjuster);
  }
  if (timestamp instanceof java.sql.Time) {
    return toIsoString((java.sql.Time) timestamp, zoneId, adjuster);
  }
  return timestamp.toInstant().atZone(zoneId).format(FORMATTER);
}

代码示例来源:origin: debezium/debezium

@Override
public SchemaBuilder schemaBuilder(Column column) {
  switch (column.jdbcType()) {
    // Numeric integers
    case Types.TINYINT:
      // values are an 8-bit unsigned integer value between 0 and 255, we thus need to store it in short int
      return SchemaBuilder.int16();
    // Floating point
    case microsoft.sql.Types.SMALLMONEY:
    case microsoft.sql.Types.MONEY:
      return SpecialValueDecimal.builder(decimalMode, column.length(), column.scale().get());
    case microsoft.sql.Types.DATETIMEOFFSET:
      return ZonedTimestamp.builder();
    default:
      return super.schemaBuilder(column);
  }
}

代码示例来源:origin: debezium/debezium

return toIsoString((OffsetDateTime) value, adjuster);
return toIsoString((ZonedDateTime) value, adjuster);
return toIsoString((OffsetTime) value, adjuster);
return toIsoString((java.util.Date) value, defaultZone, adjuster);

代码示例来源:origin: debezium/debezium

return ZonedTime.builder();
case Types.TIMESTAMP_WITH_TIMEZONE:
  return ZonedTimestamp.builder();

代码示例来源:origin: debezium/debezium

/**
 * Converts a value object for an expected JDBC type of {@link Types#TIMESTAMP_WITH_TIMEZONE}.
 * The <a href="http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html">standard ANSI to Java 8 type
 * mappings</a> specify that the preferred mapping (when using JDBC's {@link java.sql.ResultSet#getObject(int) getObject(...)}
 * methods) in Java 8 is to return {@link OffsetDateTime} for these values.
 * <p>
 * This method handles several types of objects, including {@link OffsetDateTime}, {@link java.sql.Timestamp},
 * {@link java.util.Date}, {@link java.time.LocalTime}, and {@link java.time.LocalDateTime}.
 *
 * @param column the column definition describing the {@code data} value; never null
 * @param fieldDefn the field definition; never null
 * @param data the data object to be converted into a {@link Date Kafka Connect date} type; never null
 * @return the converted value, or null if the conversion could not be made and the column allows nulls
 * @throws IllegalArgumentException if the value could not be converted but the column does not allow nulls
 */
protected Object convertTimestampWithZone(Column column, Field fieldDefn, Object data) {
  // epoch is the fallback value
  return convertValue(column, fieldDefn, data, OffsetDateTime.of(LocalDate.ofEpochDay(0), LocalTime.MIDNIGHT, defaultOffset), (r) -> {
    try {
      r.deliver(ZonedTimestamp.toIsoString(data, defaultOffset, adjuster));
    } catch (IllegalArgumentException e) {
    }
  });
}

代码示例来源:origin: debezium/debezium

case PgOid.TIMESTAMPTZ:
  return ZonedTimestamp.builder();
case PgOid.TIMETZ:

代码示例来源:origin: debezium/debezium

String isoString = ZonedTimestamp.toIsoString(t, ZoneId.systemDefault(), MySqlValueConverters::adjustTemporal);
assertThat(schemaB.defaultValue()).isEqualTo(isoString);

代码示例来源:origin: debezium/debezium

Bits.builder(2).optional().build());
assertTableSchema("public.time_table", "ts, tz, date, ti, ttz, it",
         MicroTimestamp.builder().optional().build(), ZonedTimestamp.builder().optional().build(),
         Date.builder().optional().build(), MicroTime.builder().optional().build(), ZonedTime.builder().optional().build(),
         MicroDuration.builder().optional().build());

代码示例来源:origin: debezium/debezium

String isoString = ZonedTimestamp.toIsoString(t, ZoneId.systemDefault(), MySqlValueConverters::adjustTemporal);
assertThat(schemaB.defaultValue()).isEqualTo(isoString);

代码示例来源:origin: io.debezium/debezium-core

/**
 * Returns a Schema for a {@link ZonedTimestamp} but with all other default Schema settings.
 * 
 * @return the schema
 * @see #builder()
 */
public static Schema schema() {
  return builder().build();
}

代码示例来源:origin: debezium/debezium

String isoString = ZonedTimestamp.toIsoString(t, ZoneId.systemDefault(), MySqlValueConverters::adjustTemporal);
assertThat(schemaB.defaultValue()).isEqualTo(isoString);
String isoString5 = ZonedTimestamp.toIsoString(t5, ZoneOffset.UTC, MySqlValueConverters::adjustTemporal);
assertThat(schemaJ.defaultValue()).isEqualTo(
    MySQLConnection.forTestDatabase(DATABASE.getDatabaseName())

代码示例来源:origin: io.debezium/debezium-connector-oracle

@Override
public SchemaBuilder schemaBuilder(Column column) {
  logger.debug("Building schema for column {} of type {} named {} with constraints ({},{})",
      column.name(),
      column.jdbcType(),
      column.typeName(),
      column.length(),
      column.scale()
  );
  switch (column.jdbcType()) {
    // Oracle's float is not float as in Java but a NUMERIC without scale
    case Types.FLOAT:
      return VariableScaleDecimal.builder();
    case Types.NUMERIC:
      return getNumericSchema(column);
    case OracleTypes.BINARY_FLOAT:
      return SchemaBuilder.float32();
    case OracleTypes.BINARY_DOUBLE:
      return SchemaBuilder.float64();
    case OracleTypes.TIMESTAMPTZ:
    case OracleTypes.TIMESTAMPLTZ:
      return ZonedTimestamp.builder();
    case OracleTypes.INTERVALYM:
    case OracleTypes.INTERVALDS:
      return MicroDuration.builder();
    default:
      return super.schemaBuilder(column);
  }
}

代码示例来源:origin: debezium/debezium

String isoStringA = ZonedTimestamp.toIsoString(a, ZoneOffset.UTC, MySqlValueConverters::adjustTemporal);
assertThat(schemaA.defaultValue()).isEqualTo(isoStringA);

代码示例来源:origin: io.debezium/debezium-core

return ZonedTime.builder();
case Types.TIMESTAMP_WITH_TIMEZONE:
  return ZonedTimestamp.builder();

代码示例来源:origin: io.debezium/debezium-core

/**
 * Get the ISO 8601 formatted representation of the given {@link java.util.Date} or one of its JDBC subclasses, using
 * the supplied timezone information.
 * 
 * @param timestamp the timestamp value
 * @param zoneId the timezone identifier or offset where the timestamp is defined
 * @param adjuster the optional component that adjusts the local date value before obtaining the epoch day; may be null if no
 * adjustment is necessary
 * @return the ISO 8601 formatted string
 */
public static String toIsoString(java.util.Date timestamp, ZoneId zoneId, TemporalAdjuster adjuster) {
  if (timestamp instanceof java.sql.Timestamp) {
    return toIsoString((java.sql.Timestamp) timestamp, zoneId, adjuster);
  }
  if (timestamp instanceof java.sql.Date) {
    return toIsoString((java.sql.Date) timestamp, zoneId, adjuster);
  }
  if (timestamp instanceof java.sql.Time) {
    return toIsoString((java.sql.Time) timestamp, zoneId, adjuster);
  }
  return timestamp.toInstant().atZone(zoneId).format(FORMATTER);
}

代码示例来源:origin: io.debezium/debezium-connector-postgres

case PgOid.TIMESTAMPTZ:
  return ZonedTimestamp.builder();
case PgOid.TIMETZ:

代码示例来源:origin: io.debezium/debezium-core

return toIsoString((OffsetDateTime) value, adjuster);
return toIsoString((ZonedDateTime) value, adjuster);
return toIsoString((OffsetTime) value, adjuster);
return toIsoString((java.util.Date) value, defaultZone, adjuster);

代码示例来源:origin: io.debezium/debezium-connector-postgres

Bits.builder(2).optional().build());
assertTableSchema("public.time_table", "ts, tz, date, ti, ttz, it",
         MicroTimestamp.builder().optional().build(), ZonedTimestamp.builder().optional().build(),
         Date.builder().optional().build(), MicroTime.builder().optional().build(), ZonedTime.builder().optional().build(),
         MicroDuration.builder().optional().build());

代码示例来源:origin: io.debezium/debezium-core

/**
 * Converts a value object for an expected JDBC type of {@link Types#TIMESTAMP_WITH_TIMEZONE}.
 * The <a href="http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html">standard ANSI to Java 8 type
 * mappings</a> specify that the preferred mapping (when using JDBC's {@link java.sql.ResultSet#getObject(int) getObject(...)}
 * methods) in Java 8 is to return {@link OffsetDateTime} for these values.
 * <p>
 * This method handles several types of objects, including {@link OffsetDateTime}, {@link java.sql.Timestamp},
 * {@link java.util.Date}, {@link java.time.LocalTime}, and {@link java.time.LocalDateTime}.
 *
 * @param column the column definition describing the {@code data} value; never null
 * @param fieldDefn the field definition; never null
 * @param data the data object to be converted into a {@link Date Kafka Connect date} type; never null
 * @return the converted value, or null if the conversion could not be made and the column allows nulls
 * @throws IllegalArgumentException if the value could not be converted but the column does not allow nulls
 */
protected Object convertTimestampWithZone(Column column, Field fieldDefn, Object data) {
  // epoch is the fallback value
  return convertValue(column, fieldDefn, data, OffsetDateTime.of(LocalDate.ofEpochDay(0), LocalTime.MIDNIGHT, defaultOffset), (r) -> {
    try {
      r.deliver(ZonedTimestamp.toIsoString(data, defaultOffset, adjuster));
    } catch (IllegalArgumentException e) {
    }
  });
}

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com