1.日期解析失败返回null; 2.升级netty依赖.

master
剑器近 2021-04-07 17:46:51 +08:00
parent d69b5169e8
commit 635b9d8b82
2 changed files with 13 additions and 9 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.yezhihao</groupId>
<artifactId>protostar</artifactId>
<version>1.0.3.RELEASE</version>
<version>1.0.4.RELEASE</version>
<packaging>jar</packaging>
<name>Protostar</name>
@ -62,7 +62,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>4.1.58.Final</version>
<version>4.1.63.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -64,13 +64,17 @@ public class Bcd {
int year = HUNDRED_YEAR + num(bcd[i - 5]);
if (year < YEAR_RANGE)
year += 100;
return LocalDateTime.of(
year,
num(bcd[i - 4]),
num(bcd[i - 3]),
num(bcd[i - 2]),
num(bcd[i - 1]),
num(bcd[i]));
try {
return LocalDateTime.of(
year,
num(bcd[i - 4]),
num(bcd[i - 3]),
num(bcd[i - 2]),
num(bcd[i - 1]),
num(bcd[i]));
} catch (Exception e) {
return null;
}
}
/** 日期转BCD (yyMMdd) */