mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
429c12135e
commit
2665469612
@ -16,6 +16,7 @@ import org.dromara.hutool.core.date.DateException;
|
||||
import org.dromara.hutool.core.date.DatePattern;
|
||||
import org.dromara.hutool.core.date.DateTime;
|
||||
import org.dromara.hutool.core.date.format.DefaultDateBasic;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.core.regex.ReUtil;
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
import org.dromara.hutool.core.text.CharUtil;
|
||||
@ -53,8 +54,9 @@ public class ISO8601DateParser extends DefaultDateBasic implements DateParser {
|
||||
|
||||
final int patternLength = DatePattern.UTC_MS_PATTERN.length();
|
||||
// 格式类似:2018-09-13T05:34:31.999Z,-4表示减去4个单引号的长度
|
||||
// -4 ~ -6范围表示匹配毫秒1~3位的情况
|
||||
if (length <= patternLength - 4 && length >= patternLength - 6) {
|
||||
// 2018-09-13T05:34:31.1Z - 2018-09-13T05:34:31.000000Z
|
||||
if (length <= patternLength && length >= patternLength - 6) {
|
||||
// 毫秒部分1-7位支持
|
||||
return new DateTime(source, DatePattern.UTC_MS_FORMAT);
|
||||
}
|
||||
} else if (StrUtil.contains(source, '+')) {
|
||||
|
@ -1088,4 +1088,11 @@ public class DateUtilTest {
|
||||
Assertions.assertEquals(71, DateUtil.age(DateUtil.parse("1952-02-13"), DateUtil.parse("2023-02-14")));
|
||||
Assertions.assertEquals(0, DateUtil.age(DateUtil.parse("2023-02-14"), DateUtil.parse("2023-02-14")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void issueI7H34NTest() {
|
||||
final DateTime parse = DateUtil.parse("2019-10-22T09:56:03.000123Z");
|
||||
Assertions.assertNotNull(parse);
|
||||
Assertions.assertEquals("2019-10-22 09:56:03", parse.toString());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user