Package io.debezium.time
Class ZonedTime
- java.lang.Object
-
- io.debezium.time.ZonedTime
-
public class ZonedTime extends Object
A utility for converting various Java time representations into theSTRINGrepresentation of the time in a particular time zone, and for defining a Kafka ConnectSchemafor zoned time values.The ISO date-time format includes the time (including fractional parts) and offset from UTC, such as '10:15:30+01:00'.
- Author:
- Randall Hauch
- See Also:
Date,Time,Timestamp,ZonedTime,ZonedTimestamp
-
-
Field Summary
Fields Modifier and Type Field Description static DateTimeFormatterFORMATTERstatic StringSCHEMA_NAME
-
Constructor Summary
Constructors Modifier Constructor Description privateZonedTime()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.kafka.connect.data.SchemaBuilderbuilder()Returns aSchemaBuilderfor aZonedTime.static org.apache.kafka.connect.data.Schemaschema()Returns a Schema for aZonedTimebut with all other default Schema settings.static StringtoIsoString(Object value, ZoneId defaultZone, TemporalAdjuster adjuster)Get the ISO 8601 formatted representation of the givenLocalDateTime,LocalDate,LocalTime,Date,Date,Time,Timestamp,OffsetTime, orOffsetDateTime, ignoring any date portions of the supplied value.static StringtoIsoString(Date date, ZoneId zoneId, TemporalAdjuster adjuster)Get the ISO 8601 formatted representation of the givenDate, which contains a date but no time or timezone information.static StringtoIsoString(Time time, ZoneId zoneId, TemporalAdjuster adjuster)Get the ISO 8601 formatted representation of the givenTime, which contains time but no date or timezone information.static StringtoIsoString(Timestamp timestamp, ZoneId zoneId, TemporalAdjuster adjuster)Get the ISO 8601 formatted representation of the givenTimestamp, which contains a date and time but has no timezone information.static StringtoIsoString(OffsetDateTime timestamp, TemporalAdjuster adjuster)Get the ISO 8601 formatted representation of the givenOffsetDateTime.static StringtoIsoString(OffsetTime timestamp, TemporalAdjuster adjuster)Get the ISO 8601 formatted representation of the givenOffsetTime.static StringtoIsoString(Date timestamp, ZoneId zoneId, TemporalAdjuster adjuster)Get the ISO 8601 formatted representation of the givenDateor one of its JDBC subclasses, using the supplied timezone information.
-
-
-
Field Detail
-
FORMATTER
public static final DateTimeFormatter FORMATTER
-
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 aSchemaBuilderfor aZonedTime. You can use the resulting SchemaBuilder to set 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 aZonedTimebut with all other default Schema settings.- Returns:
- the schema
- See Also:
builder()
-
toIsoString
public static String toIsoString(Object value, ZoneId defaultZone, TemporalAdjuster adjuster)
Get the ISO 8601 formatted representation of the givenLocalDateTime,LocalDate,LocalTime,Date,Date,Time,Timestamp,OffsetTime, orOffsetDateTime, ignoring any date portions of the supplied value.- Parameters:
value- the local or SQL date, time, or timestamp value; may not be nulldefaultZone- the time zone that should be used by default if the value does not have timezone information; may not be nulladjuster- the optional component that adjusts the local date value before obtaining the epoch day; may be null if no adjustment is necessary- Returns:
- the microseconds past midnight
- Throws:
IllegalArgumentException- if the value is not an instance of the acceptable types or is null
-
toIsoString
public static String toIsoString(OffsetDateTime timestamp, TemporalAdjuster adjuster)
Get the ISO 8601 formatted representation of the givenOffsetDateTime.- Parameters:
timestamp- the timestamp value; may not be nulladjuster- the optional component that adjusts the local date value before obtaining the epoch day; may be null if no adjustment is necessary- Returns:
- the ISO 8601 formatted string
-
toIsoString
public static String toIsoString(OffsetTime timestamp, TemporalAdjuster adjuster)
Get the ISO 8601 formatted representation of the givenOffsetTime.- Parameters:
timestamp- the timestamp value; may not be nulladjuster- the optional component that adjusts the local date value before obtaining the epoch day; may be null if no adjustment is necessary- Returns:
- the ISO 8601 formatted string
-
toIsoString
public static String toIsoString(Date timestamp, ZoneId zoneId, TemporalAdjuster adjuster)
Get the ISO 8601 formatted representation of the givenDateor one of its JDBC subclasses, using the supplied timezone information.- Parameters:
timestamp- the timestamp value; may not be nullzoneId- the timezone identifier or offset where the timestamp is definedadjuster- the optional component that adjusts the local date value before obtaining the epoch day; may be null if no adjustment is necessary- Returns:
- the ISO 8601 formatted string
-
toIsoString
public static String toIsoString(Timestamp timestamp, ZoneId zoneId, TemporalAdjuster adjuster)
Get the ISO 8601 formatted representation of the givenTimestamp, which contains a date and time but has no timezone information.- Parameters:
timestamp- the JDBC timestamp value; may not be nullzoneId- the timezone identifier or offset where the timestamp is definedadjuster- the optional component that adjusts the local date value before obtaining the epoch day; may be null if no adjustment is necessary- Returns:
- the ISO 8601 formatted string
-
toIsoString
public static String toIsoString(Date date, ZoneId zoneId, TemporalAdjuster adjuster)
Get the ISO 8601 formatted representation of the givenDate, which contains a date but no time or timezone information.- Parameters:
date- the date value; may not be nullzoneId- the timezone identifier or offset where the date is definedadjuster- the optional component that adjusts the local date value before obtaining the epoch day; may be null if no adjustment is necessary- Returns:
- the ISO 8601 formatted string
-
toIsoString
public static String toIsoString(Time time, ZoneId zoneId, TemporalAdjuster adjuster)
Get the ISO 8601 formatted representation of the givenTime, which contains time but no date or timezone information.- Parameters:
time- the JDBC time value; may not be nullzoneId- the timezone identifier or offset where the time is definedadjuster- the optional component that adjusts the local date value before obtaining the epoch day; may be null if no adjustment is necessary- Returns:
- the ISO 8601 formatted string
-
-