Package io.debezium.time
Class MicroDuration
- java.lang.Object
-
- io.debezium.time.MicroDuration
-
public class MicroDuration extends Object
A utility representing a duration into a correspondingINT64
number of microsecond, and for defining a Kafka ConnectSchema
for duration values.- Author:
- Horia Chiorean ([email protected])
-
-
Field Summary
Fields Modifier and Type Field Description static double
DAYS_PER_MONTH_AVG
The approximation used by the plugins when converting a duration to microsstatic String
SCHEMA_NAME
-
Constructor Summary
Constructors Modifier Constructor Description private
MicroDuration()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.kafka.connect.data.SchemaBuilder
builder()
Returns aSchemaBuilder
for aMicroDuration
.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
schema()
Returns a Schema for aMicroDuration
but with all other default Schema settings.
-
-
-
Field Detail
-
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:
- Constant Field Values
-
SCHEMA_NAME
public static final String SCHEMA_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
public static org.apache.kafka.connect.data.SchemaBuilder builder()
Returns aSchemaBuilder
for aMicroDuration
. The resulting schema will describe a field with the "io.debezium.time.MicroDuration" as thename
andSchemaBuilder.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 aMicroDuration
but with all other default Schema settings. The schema describes a field with the "io.debezium.time.MicroDuration" as thename
andSchemaBuilder.float64()
FLOAT64} for the literal type storing the number of microseconds.- Returns:
- the schema
- See Also:
builder()
-
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.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 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.MONTHS
is used.- Returns:
- a
BigDecimal
value which contains the number of microseconds, nevernull
-
-