Provides support for Java 8’s date & time API in JDBI.
Releases are hosted on JCenter and snapshots are hosted on oss.jfrog.org.
repositories {
jcenter()
maven { url "http://oss.jfrog.org/artifactory/repo" } // only if you need snapshots
}
dependencies {
compile "co.freeside.jdbi-time:jdbi-time:1.1"
}
<repository>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
<!-- only if you need snapshots -->
<repository>
<id>ojo</id>
<name>JFrog OSS</name>
<url>http://oss.jfrog.org/artifactory/repo</url>
</repository>
<dependency>
<groupId>co.freeside.jdbi-time</groupId>
<artifactId>jdbi-time</artifactId>
<version>1.1</version>
</dependency>
In order to use java.time types with JDBI simply register argument types and mappers like this:
dbi.registerArgumentFactory(new TimeTypesArgumentFactory());
dbi.registerMapper(new TimeTypesMapperFactory());
You can do the same on an individual Handle if that’s what you need.
Class | Column type | Example |
---|---|---|
java.time.Duration |
BIGINT |
3600000 |
java.time.Instant |
TIMESTAMP |
1403528189819 |
java.time.LocalDate |
VARCHAR |
'2014-06-23' |
java.time.LocalDateTime |
VARCHAR |
'2014-06-23T13:56:29.819' |
java.time.LocalTime |
VARCHAR |
'13:56:29.819' |
java.time.MonthDay |
VARCHAR |
'--06-23' |
java.time.Period |
VARCHAR |
'P1Y2M3D' |
java.time.YearMonth |
VARCHAR |
'2014-06' |
java.time.ZoneId |
VARCHAR |
'Europe/London' |
java.time.ZonedDateTime |
VARCHAR |
'2014-06-23T13:56:29.819+01:00[Europe/London]' |