Package io.debezium.time
Class MicroDuration
java.lang.Object
io.debezium.time.MicroDuration
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 (hchiorea@redhat.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe approximation used by the plugins when converting a duration to microsstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.kafka.connect.data.SchemaBuilderbuilder()Returns aSchemaBuilderfor aMicroDuration.static longdurationMicros(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 longdurationMicros(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.Schemaschema()Returns a Schema for aMicroDurationbut with all other default Schema settings.
-
Field Details
-
DAYS_PER_MONTH_AVG
public static final double DAYS_PER_MONTH_AVGThe approximation used by the plugins when converting a duration to micros- See Also:
-
SCHEMA_NAME
- See Also:
-
-
Constructor Details
-
MicroDuration
private MicroDuration()
-
-
Method Details
-
builder
public static org.apache.kafka.connect.data.SchemaBuilder builder()Returns aSchemaBuilderfor aMicroDuration. The resulting schema will describe a field with the "io.debezium.time.MicroDuration" as thenameandSchemaBuilder.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 aMicroDurationbut with all other default Schema settings. The schema describes a field with the "io.debezium.time.MicroDuration" as thenameandSchemaBuilder.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 yearsmonths- a number of monthsdays- a number of dayshours- a number of hoursminutes- a number of minutesseconds- a number of secondsmicros- a number of microsecondsdaysPerMonthAvg- an optional value representing a days per month average; if null, the default duration fromChronoUnit.MONTHSis 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 yearsmonths- a number of monthsdays- a number of dayshours- a number of hoursminutes- a number of minutesseconds- a number of secondsdaysPerMonthAvg- an optional value representing a days per month average; if null, the default duration fromChronoUnit.MONTHSis used.- Returns:
- a
BigDecimalvalue which contains the number of microseconds, nevernull
-