Class JDBCAdapter<S,T>
- Type Parameters:
S
- source type in JDBCT
- target type in Time4J
- All Implemented Interfaces:
Converter<S,T>
Serves as bridge to temporal types in JDBC.
All singleton instances are defined as static constants and are immutable.
- Since:
- 3.0
- Author:
- Meno Hochschild
-
Field Summary
Modifier and TypeFieldDescriptionstatic JDBCAdapter<Date,PlainDate>
Bridge between a JDBC-Date and the classPlainDate
.static JDBCAdapter<Time,PlainTime>
Bridge between a JDBC-Time and the classPlainTime
.static JDBCAdapter<Timestamp,PlainTimestamp>
Bridge between a JDBC-Timestamp and the classPlainTimestamp
.static JDBCAdapter<Timestamp,Moment>
Bridge between a JDBC-Timestamp and the classMoment
.Fields inherited from class net.time4j.TemporalType
CLOCK, INSTANT, JAVA_UTIL_CALENDAR, JAVA_UTIL_DATE, JAVA_UTIL_TIMEZONE, LOCAL_DATE, LOCAL_DATE_TIME, LOCAL_TIME, MILLIS_SINCE_UNIX, THREETEN_DURATION, THREETEN_PERIOD, ZONED_DATE_TIME
-
Method Summary
Methods inherited from class net.time4j.TemporalType
from, translate
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.time4j.engine.Converter
getSourceType
-
Field Details
-
SQL_DATE
Bridge between a JDBC-Date and the class
PlainDate
.If the system property "net.time4j.sql.utc.conversion" is set to the value "true" then the conversion will not take into account the system timezone anticipating that a SQL-DATE was created without any timezone calculation on the server side, too. That is more or less the case if UTC is the default timezone on the application server.
Example (UTC as default timezone):
java.sql.Date sqlValue = new java.sql.Date(86400 * 1000); PlainDate date = JDBCAdapter.SQL_DATE.translate(sqlValue); System.out.println(date); // output: 1970-01-02
Note: The conversion is only possible if a date has a year in the range
1900-9999
because else a JDBC-compatible database cannot store the date per SQL-specification. It is strongly recommended to interprete a SQL-DATE only as abstract JDBC object because its text output viajava.sql.Date.toString()
-method is not reliable (dependency on the gregorian-julian cutover day + possible timezone side effects). The concrete formatting can be done by Time4J for example viaPlainDate.toString()
or a suitableChronoFormatter
.- Since:
- 3.0
-
SQL_TIME
Bridge between a JDBC-Time and the class
PlainTime
.If the system property "net.time4j.sql.utc.conversion" is set to the value "true" then the conversion will NOT take into account the system timezone anticipating that a SQL-DATE was created without any timezone calculation on the server side, too. That is more or less the case if UTC is the default timezone on the application server.
Example (UTC as default timezone):
java.sql.Time sqlValue = new java.sql.Time(43200 * 1000); PlainTime time = JDBCAdapter.SQL_TIME.translate(sqlValue); System.out.println(time); // output: T12:00:00
Note: The conversion only occurs in millisecond precision at best not in in nanosecond precision so there is possible loss of data. Furthermore, the text output via the method
java.sql.Time.toString()
can be misinterpreted by timezone side effects. Concrete text output should be done by Time4J.- Since:
- 3.0
-
SQL_TIMESTAMP
Bridge between a JDBC-Timestamp and the class
PlainTimestamp
.If the system property "net.time4j.sql.utc.conversion" is set to the value "true" then the conversion will NOT take into account the system timezone anticipating that a SQL-DATE was created without any timezone calculation on the server side, too. That is more or less the case if UTC is the default timezone on the application server.
Example (UTC as default timezone):
java.sql.Timestamp sqlValue = new java.sql.Timestamp(86401 * 1000); sqlValue.setNanos(1); PlainTimestamp ts = JDBCAdapter.SQL_TIMESTAMP.translate(sqlValue); System.out.println(ts); // output: 1970-01-02T00:00:01,000000001
- Since:
- 3.0
-
SQL_TIMESTAMP_WITH_ZONE
Bridge between a JDBC-Timestamp and the class
Moment
.Notes: Leap seconds are not storable. And the maximum available precision is dependent on the database. Despite of the misleading SQL name, this conversion does not use a timezone but a timezone offset, finally
ZonalOffset.UTC
.- Since:
- 3.18/4.14
-