commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Comer (JIRA)" <j...@apache.org>
Subject [jira] [Created] (DBUTILS-116) Enhance BeanProcessor to support Joda DateTime
Date Wed, 13 Nov 2013 15:15:45 GMT
Bill Comer created DBUTILS-116:
----------------------------------

             Summary: Enhance BeanProcessor to support Joda DateTime
                 Key: DBUTILS-116
                 URL: https://issues.apache.org/jira/browse/DBUTILS-116
             Project: Commons DbUtils
          Issue Type: Improvement
    Affects Versions: 1.5
            Reporter: Bill Comer


We use the popular org.joda.time.DateTime to map all our Date fields in our POJOs.

Could this be added to BeanProcessor.callSetter(....)

I have done this local change that appears to work for me.

            if (value instanceof java.util.Date) {
                final String targetType = params[0].getName();
                if ("java.sql.Date".equals(targetType)) {
                    value = new java.sql.Date(((java.util.Date) value).getTime());
                } else
                if ("java.sql.Time".equals(targetType)) {
                    value = new java.sql.Time(((java.util.Date) value).getTime());
                } else
                if ("java.sql.Timestamp".equals(targetType)) {
                    value = new java.sql.Timestamp(((java.util.Date) value).getTime());
                } else
                if ("org.joda.time.DateTime".equals(targetType)) {
                    if (value instanceof java.sql.Timestamp) {                      
                      value = new DateTime((java.sql.Timestamp)value);
                    }
                }
            }



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message