mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
LocalDateTimeUtil.parse改为blank检查
This commit is contained in:
parent
6c1281242b
commit
e27b24005d
@ -13,6 +13,7 @@
|
|||||||
* 【core 】 修改ObjectUtil.isNull逻辑(issue#I5COJF@Gitee)
|
* 【core 】 修改ObjectUtil.isNull逻辑(issue#I5COJF@Gitee)
|
||||||
* 【core 】 BlockPolicy增加线程池关闭后的逻辑(pr#660@Gitee)
|
* 【core 】 BlockPolicy增加线程池关闭后的逻辑(pr#660@Gitee)
|
||||||
* 【core 】 Ipv4Util增加ipv4ToLong重载(pr#661@Gitee)
|
* 【core 】 Ipv4Util增加ipv4ToLong重载(pr#661@Gitee)
|
||||||
|
* 【core 】 LocalDateTimeUtil.parse改为blank检查(issue#I5CZJ9@Gitee)
|
||||||
*
|
*
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【extra 】 修复createExtractor中抛出异常后流未关闭问题(pr#2384@Github)
|
* 【extra 】 修复createExtractor中抛出异常后流未关闭问题(pr#2384@Github)
|
||||||
|
@ -229,7 +229,7 @@ public class LocalDateTimeUtil {
|
|||||||
* @return {@link LocalDateTime}
|
* @return {@link LocalDateTime}
|
||||||
*/
|
*/
|
||||||
public static LocalDateTime parse(CharSequence text, DateTimeFormatter formatter) {
|
public static LocalDateTime parse(CharSequence text, DateTimeFormatter formatter) {
|
||||||
if (null == text) {
|
if (StrUtil.isBlank(text)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (null == formatter) {
|
if (null == formatter) {
|
||||||
@ -247,7 +247,7 @@ public class LocalDateTimeUtil {
|
|||||||
* @return {@link LocalDateTime}
|
* @return {@link LocalDateTime}
|
||||||
*/
|
*/
|
||||||
public static LocalDateTime parse(CharSequence text, String format) {
|
public static LocalDateTime parse(CharSequence text, String format) {
|
||||||
if (null == text) {
|
if (StrUtil.isBlank(text)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.time.temporal.TemporalAccessor;
|
import java.time.temporal.TemporalAccessor;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class LocalDateTimeUtilTest {
|
public class LocalDateTimeUtilTest {
|
||||||
|
|
||||||
@ -237,4 +236,10 @@ public class LocalDateTimeUtilTest {
|
|||||||
final LocalDateTime of = LocalDateTimeUtil.of((TemporalAccessor) instant);
|
final LocalDateTime of = LocalDateTimeUtil.of((TemporalAccessor) instant);
|
||||||
Console.log(of);
|
Console.log(of);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parseBlankTest(){
|
||||||
|
final LocalDateTime parse = LocalDateTimeUtil.parse("");
|
||||||
|
Assert.assertNull(parse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user