
com.bendb.dropwizard.jooq.JodaDateTimeConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dropwizard-jooq Show documentation
Show all versions of dropwizard-jooq Show documentation
Addon bundle for Dropwizard to support jOOQ for database access
package com.bendb.dropwizard.jooq;
import org.joda.time.DateTime;
import org.jooq.Converter;
import java.sql.Timestamp;
/**
* A {@link org.jooq.Converter} for {@link org.joda.time.DateTime} objects.
*/
public class JodaDateTimeConverter implements Converter {
@Override
public DateTime from(Timestamp timestamp) {
return timestamp != null
? new DateTime(timestamp.getTime())
: null;
}
@Override
public Timestamp to(DateTime dateTime) {
return dateTime != null
? new Timestamp(dateTime.getMillis())
: null;
}
@Override
public Class fromType() {
return Timestamp.class;
}
@Override
public Class toType() {
return DateTime.class;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy