mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add method for DateUtil
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user