Commit e2bdac24 by 王军业

12145114

1 parent 219276ec
package com.vion.financial.handler;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
@MappedJdbcTypes({JdbcType.DATE})
@MappedTypes({Date.class})
public class MilliDateTypeHandler extends BaseTypeHandler<Date>{
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Date date, JdbcType jdbcType)
throws SQLException {
//String dateS = DateUtil.FORMAT_YYYY_MM_DD.format(date);
System.out.println("=======adsa======");
java.sql.Date sqldate = new java.sql.Date(date.getTime());
ps.setDate(i, sqldate);
}
@Override
public Date getNullableResult(ResultSet rs, String columnName) throws SQLException {
return new Date(rs.getLong(columnName));
}
@Override
public Date getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
return new Date(rs.getLong(columnIndex));
}
@Override
public Date getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
return cs.getDate(columnIndex);
}
}
package com.vion.financial.handler;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
@MappedJdbcTypes({JdbcType.DATE})
@MappedTypes({Date.class})
public class MilliDateTypeHandler extends BaseTypeHandler<Date>{
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Date date, JdbcType jdbcType)
throws SQLException {
//String dateS = DateUtil.FORMAT_YYYY_MM_DD.format(date);
//System.out.println("=======adsa======");
java.sql.Date sqldate = new java.sql.Date(date.getTime());
ps.setDate(i, sqldate);
}
@Override
public Date getNullableResult(ResultSet rs, String columnName) throws SQLException {
return new Date(rs.getLong(columnName));
}
@Override
public Date getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
return new Date(rs.getLong(columnIndex));
}
@Override
public Date getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
return cs.getDate(columnIndex);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!