Class MicroDuration

java.lang.Object
io.debezium.time.MicroDuration

public class MicroDuration extends Object
A utility representing a duration into a corresponding INT64 number of microsecond, and for defining a Kafka Connect Schema for duration values.
Author:
Horia Chiorean ([email protected])
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    The approximation used by the plugins when converting a duration to micros
    static final String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.kafka.connect.data.SchemaBuilder
    Returns a SchemaBuilder for a MicroDuration.
    static long
    durationMicros(int years, int months, int days, int hours, int minutes, double seconds, int micros, Double daysPerMonthAvg)
    Converts a number of time units to a duration in microseconds.
    static long
    durationMicros(int years, int months, int days, int hours, int minutes, double seconds, Double daysPerMonthAvg)
    Converts a number of time units to a duration in microseconds.
    static org.apache.kafka.connect.data.Schema
    Returns a Schema for a MicroDuration but with all other default Schema settings.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DAYS_PER_MONTH_AVG

      public static final double DAYS_PER_MONTH_AVG
      The approximation used by the plugins when converting a duration to micros
      See Also:
    • SCHEMA_NAME

      public static final String SCHEMA_NAME
      See Also:
  • Constructor Details

    • MicroDuration

      private MicroDuration()
  • Method Details

    • builder

      public static org.apache.kafka.connect.data.SchemaBuilder builder()
      Returns a SchemaBuilder for a MicroDuration. The resulting schema will describe a field with the "io.debezium.time.MicroDuration" as the name and SchemaBuilder.float64() FLOAT64} for the literal type storing the number of microseconds for that duration.

      You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default value, and documentation.

      Returns:
      the schema builder
    • schema

      public static org.apache.kafka.connect.data.Schema schema()
      Returns a Schema for a MicroDuration but with all other default Schema settings. The schema describes a field with the "io.debezium.time.MicroDuration" as the name and SchemaBuilder.float64() FLOAT64} for the literal type storing the number of microseconds.
      Returns:
      the schema
      See Also:
    • durationMicros

      public static long durationMicros(int years, int months, int days, int hours, int minutes, double seconds, int micros, Double daysPerMonthAvg)
      Converts a number of time units to a duration in microseconds.
      Parameters:
      years - a number of years
      months - a number of months
      days - a number of days
      hours - a number of hours
      minutes - a number of minutes
      seconds - a number of seconds
      micros - a number of microseconds
      daysPerMonthAvg - an optional value representing a days per month average; if null, the default duration from ChronoUnit.MONTHS is used.
      Returns:
    • durationMicros

      public static long durationMicros(int years, int months, int days, int hours, int minutes, double seconds, Double daysPerMonthAvg)
      Converts a number of time units to a duration in microseconds.
      Parameters:
      years - a number of years
      months - a number of months
      days - a number of days
      hours - a number of hours
      minutes - a number of minutes
      seconds - a number of seconds
      daysPerMonthAvg - an optional value representing a days per month average; if null, the default duration from ChronoUnit.MONTHS is used.
      Returns:
      a BigDecimal value which contains the number of microseconds, never null