Skip to content

robfletcher/jdbi-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JDBI Time

Build Status

Provides support for Java 8’s date & time API in JDBI.

Installation

Releases are hosted on JCenter and snapshots are hosted on oss.jfrog.org.

Via Gradle

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"
}

Via Maven

<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>

Use

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.

Supported types

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]'

About

Provides support for Java 8's date & time API in JDBI

Resources

License

Stars

Watchers

Forks

Packages

No packages published