All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bendb.dropwizard.jooq.JodaDateTimeConverter Maven / Gradle / Ivy

There is a newer version: 3.0.0-0
Show newest version
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