mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix buf
This commit is contained in:
parent
0b74d3769d
commit
670cb3c10b
@ -7,6 +7,7 @@
|
||||
|
||||
### 新特性
|
||||
### Bug修复
|
||||
* 【core 】 修复DateUtil.parse解析2020-5-8 3:12:13错误问题(issue#I1IZA3@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
## 5.3.6 (2020-05-30)
|
||||
|
@ -909,37 +909,29 @@ public class DateUtil extends CalendarUtil {
|
||||
return parseUTC(dateStr);
|
||||
}
|
||||
|
||||
if (length == DatePattern.NORM_DATETIME_PATTERN.length()) {
|
||||
// yyyy-MM-dd HH:mm:ss
|
||||
return parseDateTime(dateStr);
|
||||
} else if (length == DatePattern.NORM_DATE_PATTERN.length()) {
|
||||
// yyyy-MM-dd
|
||||
return parseDate(dateStr);
|
||||
} else if (length == DatePattern.NORM_DATETIME_MINUTE_PATTERN.length()) {
|
||||
// yyyy-MM-dd HH:mm
|
||||
return parse(normalize(dateStr), DatePattern.NORM_DATETIME_MINUTE_FORMAT);
|
||||
} else if (length >= DatePattern.NORM_DATETIME_MS_PATTERN.length() - 2) {
|
||||
//yyyy-MM-dd HH:mm:ss.SSS
|
||||
return parse(normalize(dateStr), DatePattern.NORM_DATETIME_MS_FORMAT);
|
||||
}
|
||||
|
||||
//含有单个位数数字的日期时间格式
|
||||
//标准日期格式(包括单个数字的日期时间)
|
||||
dateStr = normalize(dateStr);
|
||||
if (ReUtil.isMatch(DatePattern.REGEX_NORM, dateStr)) {
|
||||
final int colonCount = StrUtil.count(dateStr, CharUtil.COLON);
|
||||
switch (colonCount) {
|
||||
case 0:
|
||||
// yyyy-MM-dd
|
||||
return parseDate(dateStr);
|
||||
return parse(dateStr, DatePattern.NORM_DATE_FORMAT);
|
||||
case 1:
|
||||
// yyyy-MM-dd HH:mm
|
||||
return parse(normalize(dateStr), DatePattern.NORM_DATETIME_MINUTE_FORMAT);
|
||||
return parse(dateStr, DatePattern.NORM_DATETIME_MINUTE_FORMAT);
|
||||
case 2:
|
||||
// yyyy-MM-dd HH:mm:ss
|
||||
return parseDateTime(dateStr);
|
||||
return parse(dateStr, DatePattern.NORM_DATETIME_FORMAT);
|
||||
}
|
||||
}
|
||||
|
||||
// 长度判断
|
||||
if (length >= DatePattern.NORM_DATETIME_MS_PATTERN.length() - 2) {
|
||||
//yyyy-MM-dd HH:mm:ss.SSS
|
||||
return parse(dateStr, DatePattern.NORM_DATETIME_MS_FORMAT);
|
||||
}
|
||||
|
||||
// 没有更多匹配的时间格式
|
||||
throw new DateException("No format fit for date String [{}] !", dateStr);
|
||||
}
|
||||
|
@ -777,5 +777,7 @@ public class DateUtilTest {
|
||||
Assert.assertEquals("2020-05-08 03:12:03", dateTime.toString());
|
||||
dateTime = DateUtil.parse("2020-5-8 3:2:3");
|
||||
Assert.assertEquals("2020-05-08 03:02:03", dateTime.toString());
|
||||
dateTime = DateUtil.parse("2020-5-8 3:12:13");
|
||||
Assert.assertEquals("2020-05-08 03:12:13", dateTime.toString());
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
<properties>
|
||||
<!-- versions -->
|
||||
<bouncycastle.version>1.64</bouncycastle.version>
|
||||
<bouncycastle.version>1.65.01</bouncycastle.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
Loading…
Reference in New Issue
Block a user