Package io.debezium.time
Class NanoTime
- java.lang.Object
-
- io.debezium.time.NanoTime
-
public class NanoTime extends Object
A utility for converting various Java time representations into theINT64
number of nanoseconds since midnight, and for defining a Kafka ConnectSchema
for time values with no date or timezone information.- Author:
- Randall Hauch
- See Also:
Time
,MicroTime
,Date
,Timestamp
,MicroTimestamp
,NanoTimestamp
,ZonedTime
,ZonedTimestamp
-
-
Field Summary
Fields Modifier and Type Field Description private static Duration
ONE_DAY
static String
SCHEMA_NAME
-
Constructor Summary
Constructors Modifier Constructor Description private
NanoTime()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.kafka.connect.data.SchemaBuilder
builder()
Returns aSchemaBuilder
for aNanoTime
.static org.apache.kafka.connect.data.Schema
schema()
Returns a Schema for aNanoTime
but with all other default Schema settings.static long
toNanoOfDay(Object value, boolean acceptLargeValues)
Get the number of nanoseconds past midnight of the givenDuration
.
-
-
-
Field Detail
-
SCHEMA_NAME
public static final String SCHEMA_NAME
- See Also:
- Constant Field Values
-
ONE_DAY
private static final Duration ONE_DAY
-
-
Method Detail
-
builder
public static org.apache.kafka.connect.data.SchemaBuilder builder()
Returns aSchemaBuilder
for aNanoTime
. The resulting schema will describe a field with the "io.debezium.time.NanoTime" as thename
andINT64
for the literal type storing the number of nanoseconds past midnight.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 aNanoTime
but with all other default Schema settings. The schema describes a field with the "io.debezium.time.NanoTime" as thename
andINT64
for the literal type storing the number of nanoseconds past midnight.- Returns:
- the schema
- See Also:
builder()
-
toNanoOfDay
public static long toNanoOfDay(Object value, boolean acceptLargeValues)
Get the number of nanoseconds past midnight of the givenDuration
.- Parameters:
value
- the duration value; may not be nullacceptLargeValues
- whether to accept values less than 00:00:00 and larger than 24:00:00 or not- Returns:
- the milliseconds past midnight
- Throws:
IllegalArgumentException
- if the value is not an instance of the acceptable types or it is out of the supported range
-
-