From f5ef46abd3908268f393453d0723f0ac7f535c17 Mon Sep 17 00:00:00 2001 From: Date: Mon, 17 Mar 2025 01:24:18 +0000 Subject: [PATCH] =?UTF-8?q?2025/3/17=2009:23:10---=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E4=B8=8E=E6=97=B6=E9=97=B4=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StringToTimestampTypeHandler.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/camel-mybatis-yml/StringToTimestampTypeHandler.java b/camel-mybatis-yml/StringToTimestampTypeHandler.java index b839e4e..bb6251e 100644 --- a/camel-mybatis-yml/StringToTimestampTypeHandler.java +++ b/camel-mybatis-yml/StringToTimestampTypeHandler.java @@ -7,36 +7,36 @@ import java.sql.SQLException; import java.text.ParseException; import java.text.SimpleDateFormat; -import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.TypeHandler; import org.apache.ibatis.type.JdbcType; -public class StringToTimestampTypeHandler extends BaseTypeHandler { +public class StringToTimestampTypeHandler implements TypeHandler { private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - + @Override - public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException { + public void setParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException { try { ps.setLong(i, FORMAT.parse(parameter).getTime()); } catch (ParseException e) { throw new SQLException("日期格式解析错误", e); } } - + @Override - public String getNullableResult(ResultSet rs, String columnName) throws SQLException { + public String getResult(ResultSet rs, String columnName) throws SQLException { long timestamp = rs.getLong(columnName); return timestamp == 0 ? null : FORMAT.format(new java.util.Date(timestamp)); } - + @Override - public String getNullableResult(ResultSet rs, int columnIndex) throws SQLException { + public String getResult(ResultSet rs, int columnIndex) throws SQLException { long timestamp = rs.getLong(columnIndex); return timestamp == 0 ? null : FORMAT.format(new java.util.Date(timestamp)); } - + @Override - public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { - long timestamp = cs.getLong(columnIndex); + public String getResult(CallableStatement cs, int columnIndex) throws SQLException { + long timestamp = cs.getLong(columnIndex); return timestamp == 0 ? null : FORMAT.format(new java.util.Date(timestamp)); } } \ No newline at end of file