mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
为数据库字段添加日期转换函数 支持mysql和oracle
This commit is contained in:
@@ -23,6 +23,7 @@ import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
public class JdbcUtilsTest extends TestCase {
|
||||
@@ -79,4 +80,12 @@ public class JdbcUtilsTest extends TestCase {
|
||||
Assert.assertEquals(0, list.size());
|
||||
}
|
||||
}
|
||||
|
||||
public void test_formatColumnToDateType(){
|
||||
String colunExp = JdbcUtils.formatColumnToDateType("gmt_create","oo","",JdbcConstants.ORACLE);
|
||||
Assert.assertEquals("TO_DATE(oo.gmt_create,'yyyy-mm-dd hh24:mi:ss')", colunExp);
|
||||
|
||||
String colunExp2 = JdbcUtils.formatColumnToDateType("gmt_create","oo","",JdbcConstants.MYSQL);
|
||||
Assert.assertEquals("STR_TO_DATE(oo.gmt_create,'%Y-%m-%d %H:%i:%s')", colunExp2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user