ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject Re: mm/dd/yy format issue (urgent)
Date Wed, 07 Oct 2009 17:31:06 GMT
If the datatype on your table is defined as a DATE or DATETIME or 
TIMESTAMP, then you should not be trying to supply a String format to your 
SQL. You should be using a java.util.Date or java.util.Calendar. You can 
even provide a Custom Type Handler for this to ensure that the value that 
you supply to iBatis is a java.util.Calendar and the value returned from 
iBatis is a java.util.Calendar.

        /* (non-Javadoc)
         * @see 
        public Object getResult(ResultGetter getter) throws SQLException {
                java.util.Calendar cal = java.util.Calendar.getInstance();
                java.sql.Timestamp ts = getter.getTimestamp(cal);

                if (getter.wasNull())
                        return null;
                // This is due to some odd behavior when dealing with 
proxy objects.
                if(ts == null) {
                        cal = null;
                else {
                return cal;

        /* (non-Javadoc)
         * @see 

        public void setParameter(ParameterSetter setter, Object parameter)
                        throws SQLException {

                if(parameter == null) {
                else {
                        java.util.Calendar cal = 
java.sql.Timestamp(cal.getTimeInMillis()), cal);

However, if your column is defined as a VARCHAR and you need to use a 
String format for comparison, then I would use a Custom Type Handler to 
format the supplied Date object into a String for the given format 
utilizing the java.text.DateFormat.

Chris Mathrusse

mm/dd/yy format issue (urgent)

10/07/2009 04:12 AM

Please respond to user-java

Hi all,

in my ibatis query , ihave to use both mm/dd/yyyy and mm/dd/yy . can you
please tell me how can we do that. 
 i have one question right now in my ibatis query i am using mm/dd/yyyy
format if i have given date in that format  like 02/03/2009 i am getting
results , if i changed the date format mm/dd/yy  like 02/03/09  by  giving
this format i am not getting results .

if any one knows anws for these question plz reply me it is very urgent 
View this message in context: 

Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org

  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message