未验证 提交 226bdf67 编写于 作者: L Liang Zhang 提交者: GitHub

Merge pull request #2879 from tuohai666/date

fix getString() from Date format error
...@@ -125,6 +125,8 @@ public final class ResultSetUtil { ...@@ -125,6 +125,8 @@ public final class ResultSetUtil {
return new Time(date.getTime()); return new Time(date.getTime());
case "java.sql.Timestamp": case "java.sql.Timestamp":
return new Timestamp(date.getTime()); return new Timestamp(date.getTime());
case "java.lang.String":
return date.toString();
default: default:
throw new ShardingException("Unsupported Date type:%s", convertType); throw new ShardingException("Unsupported Date type:%s", convertType);
} }
......
...@@ -84,6 +84,7 @@ public final class ResultSetUtilTest { ...@@ -84,6 +84,7 @@ public final class ResultSetUtilTest {
assertThat((java.sql.Date) ResultSetUtil.convertValue(now, java.sql.Date.class), is(now)); assertThat((java.sql.Date) ResultSetUtil.convertValue(now, java.sql.Date.class), is(now));
assertThat((Time) ResultSetUtil.convertValue(now, Time.class), is(now)); assertThat((Time) ResultSetUtil.convertValue(now, Time.class), is(now));
assertThat((Timestamp) ResultSetUtil.convertValue(now, Timestamp.class), is(new Timestamp(now.getTime()))); assertThat((Timestamp) ResultSetUtil.convertValue(now, Timestamp.class), is(new Timestamp(now.getTime())));
assertThat((String) ResultSetUtil.convertValue(now, String.class), is(now.toString()));
} }
@Test @Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册