mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -136,6 +136,13 @@ public class DateConverter extends AbstractConverter {
|
||||
return DateUtil.date(mills);
|
||||
}
|
||||
|
||||
return SqlDateUtil.wrap(targetClass, mills);
|
||||
final String dateClassName = targetClass.getName();
|
||||
if(dateClassName.startsWith("java.sql.")){
|
||||
// 为了解决在JDK9+模块化项目中用户没有引入java.sql模块导致的问题,此处增加判断
|
||||
// 如果targetClass是java.sql的类,说明引入了此模块
|
||||
return SqlDateUtil.wrap(targetClass, mills);
|
||||
}
|
||||
|
||||
throw new ConvertException("Unsupported target Date type: {}", targetClass.getName());
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@ import org.dromara.hutool.core.lang.Assert;
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* {@code java.sql.*}日期时间相关封装<br>
|
||||
@@ -80,12 +79,6 @@ public class SqlDateUtil {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends java.util.Date> T wrap(final Class<?> targetClass, final long mills) {
|
||||
// 返回指定类型
|
||||
if (java.util.Date.class == targetClass) {
|
||||
return (T) new Date(mills);
|
||||
}
|
||||
if (DateTime.class == targetClass) {
|
||||
return (T) DateUtil.date(mills);
|
||||
}
|
||||
if (java.sql.Date.class == targetClass) {
|
||||
return (T) new java.sql.Date(mills);
|
||||
}
|
||||
|
@@ -12,7 +12,6 @@
|
||||
|
||||
package org.dromara.hutool.core.cache;
|
||||
|
||||
import org.dromara.hutool.core.cache.SimpleCache;
|
||||
import org.dromara.hutool.core.thread.ConcurrencyTester;
|
||||
import org.dromara.hutool.core.thread.ThreadUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
Reference in New Issue
Block a user