From 635b9d8b82723d410cdd11e89d7d83d5f811dec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=89=91=E5=99=A8=E8=BF=91?= Date: Wed, 7 Apr 2021 17:46:51 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=97=A5=E6=9C=9F=E8=A7=A3=E6=9E=90=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E8=BF=94=E5=9B=9Enull;=202.=E5=8D=87=E7=BA=A7netty?= =?UTF-8?q?=E4=BE=9D=E8=B5=96.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 ++-- .../io/github/yezhihao/protostar/util/Bcd.java | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 5ae991b..c737b7d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 io.github.yezhihao protostar - 1.0.3.RELEASE + 1.0.4.RELEASE jar Protostar @@ -62,7 +62,7 @@ io.netty netty-buffer - 4.1.58.Final + 4.1.63.Final provided diff --git a/src/main/java/io/github/yezhihao/protostar/util/Bcd.java b/src/main/java/io/github/yezhihao/protostar/util/Bcd.java index e215c61..01ba79d 100644 --- a/src/main/java/io/github/yezhihao/protostar/util/Bcd.java +++ b/src/main/java/io/github/yezhihao/protostar/util/Bcd.java @@ -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) */