Commit e2bdac24 by 王军业

12145114

1 parent 219276ec
package com.vion.financial.handler; package com.vion.financial.handler;
import java.sql.CallableStatement; import java.sql.CallableStatement;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Date; import java.util.Date;
import org.apache.ibatis.type.BaseTypeHandler; import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes; import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes; import org.apache.ibatis.type.MappedTypes;
@MappedJdbcTypes({JdbcType.DATE}) @MappedJdbcTypes({JdbcType.DATE})
@MappedTypes({Date.class}) @MappedTypes({Date.class})
public class MilliDateTypeHandler extends BaseTypeHandler<Date>{ public class MilliDateTypeHandler extends BaseTypeHandler<Date>{
@Override @Override
public void setNonNullParameter(PreparedStatement ps, int i, Date date, JdbcType jdbcType) public void setNonNullParameter(PreparedStatement ps, int i, Date date, JdbcType jdbcType)
throws SQLException { throws SQLException {
//String dateS = DateUtil.FORMAT_YYYY_MM_DD.format(date); //String dateS = DateUtil.FORMAT_YYYY_MM_DD.format(date);
System.out.println("=======adsa======"); //System.out.println("=======adsa======");
java.sql.Date sqldate = new java.sql.Date(date.getTime()); java.sql.Date sqldate = new java.sql.Date(date.getTime());
ps.setDate(i, sqldate); ps.setDate(i, sqldate);
} }
@Override @Override
public Date getNullableResult(ResultSet rs, String columnName) throws SQLException { public Date getNullableResult(ResultSet rs, String columnName) throws SQLException {
return new Date(rs.getLong(columnName)); return new Date(rs.getLong(columnName));
} }
@Override @Override
public Date getNullableResult(ResultSet rs, int columnIndex) throws SQLException { public Date getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
return new Date(rs.getLong(columnIndex)); return new Date(rs.getLong(columnIndex));
} }
@Override @Override
public Date getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { public Date getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
return cs.getDate(columnIndex); 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!