mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add method
This commit is contained in:
parent
4e3f2153c5
commit
74d9f0e586
@ -12,6 +12,7 @@
|
||||
* 【core 】 使多个xxxBuilder实现Builder接口,扩展CheckedUtil(pr#545@Gitee)
|
||||
* 【core 】 CheckedUtil删除第二个参数为RuntimeException的方法
|
||||
* 【core 】 FileUtil增加getTotalLines方法
|
||||
* 【db 】 MetaUtil增加getTableMeta重载(issue#2157@Github)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【cache 】 修复ReentrantCache.toString方法线程不安全问题(issue#2140@Github)
|
||||
|
@ -1,9 +1,12 @@
|
||||
package cn.hutool.core.date;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ChineseDateTest {
|
||||
|
||||
@Test
|
||||
@ -113,4 +116,12 @@ public class ChineseDateTest {
|
||||
final String chineseMonth = springFestival.getChineseMonth();
|
||||
Assert.assertEquals("一月", chineseMonth);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dayTest(){
|
||||
Date date = DateUtil.parse("1900-01-31");
|
||||
//Date date = DateUtil.parse("2022-02-22","yyyy-MM-dd");
|
||||
ChineseDate chineseDate = new ChineseDate(date);
|
||||
Console.log(chineseDate);
|
||||
}
|
||||
}
|
||||
|
@ -185,15 +185,38 @@ public class MetaUtil {
|
||||
* @return Table对象
|
||||
*/
|
||||
public static Table getTableMeta(DataSource ds, String tableName) {
|
||||
return getTableMeta(ds, null, null, tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得表的元信息<br>
|
||||
* 注意如果需要获取注释,某些数据库如MySQL,需要在配置中添加:
|
||||
* <pre>
|
||||
* remarks = true
|
||||
* useInformationSchema = true
|
||||
* </pre>
|
||||
*
|
||||
* @param ds 数据源
|
||||
* @param tableName 表名
|
||||
* @param catalog catalog name,{@code null}表示自动获取,见:{@link #getCataLog(Connection)}
|
||||
* @param schema a schema name pattern,{@code null}表示自动获取,见:{@link #getSchema(Connection)}
|
||||
* @return Table对象
|
||||
* @since 5.7.22
|
||||
*/
|
||||
public static Table getTableMeta(DataSource ds, String catalog, String schema, String tableName) {
|
||||
final Table table = Table.create(tableName);
|
||||
Connection conn = null;
|
||||
try {
|
||||
conn = ds.getConnection();
|
||||
|
||||
// catalog和schema获取失败默认使用null代替
|
||||
final String catalog = getCataLog(conn);
|
||||
if(null == catalog){
|
||||
catalog = getCataLog(conn);
|
||||
}
|
||||
table.setCatalog(catalog);
|
||||
final String schema = getSchema(conn);
|
||||
if(null == schema){
|
||||
schema = getSchema(conn);
|
||||
}
|
||||
table.setSchema(schema);
|
||||
|
||||
final DatabaseMetaData metaData = conn.getMetaData();
|
||||
|
Loading…
x
Reference in New Issue
Block a user