mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
add method for DateUtil
This commit is contained in:
parent
154786ebe0
commit
00b632df99
@ -8,9 +8,11 @@
|
||||
### 新特性
|
||||
* 【poi 】 Excel合并单元格读取同一个值,不再为空
|
||||
* 【core 】 增加EscapeUtil.escapeAll(issue#758@Github)
|
||||
* 【core 】 增加formatLocalDateTime和parseLocalDateTime方法(pr#97@Gitee)
|
||||
|
||||
### Bug修复
|
||||
* 【core 】 修复EscapeUtil.escape转义错误(issue#758@Github)
|
||||
* 【core 】 修复Convert.toLocalDateTime(Object value, Date defaultValue)返回结果不是LocalDateTime类型的问题(pr#97@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -471,6 +471,18 @@ public class Convert {
|
||||
public static LocalDateTime toLocalDateTime(Object value, LocalDateTime defaultValue) {
|
||||
return convertQuietly(LocalDateTime.class, value, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为LocalDateTime<br>
|
||||
* 如果给定的值为空,或者转换失败,返回<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static LocalDateTime toLocalDateTime(Object value) {
|
||||
return toLocalDateTime(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instant<br>
|
||||
@ -499,18 +511,6 @@ public class Convert {
|
||||
return toDate(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为LocalDateTime<br>
|
||||
* 如果给定的值为空,或者转换失败,返回<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static LocalDateTime toLocalDateTime(Object value) {
|
||||
return toLocalDateTime(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
|
@ -714,8 +714,7 @@ public class DateUtil {
|
||||
public static LocalDateTime parseLocalDateTime(CharSequence dateStr, String format) {
|
||||
dateStr = normalize(dateStr);
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
|
||||
LocalDateTime ldt = LocalDateTime.parse(dateStr,df);
|
||||
return ldt;
|
||||
return LocalDateTime.parse(dateStr,df);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user