Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
s_guodong
gjjs-bd-common
Commits
a9ca9687
Commit
a9ca9687
authored
Dec 21, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化错误格式时间拦截
parent
063f14ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletions
+5
-1
MyDateDeSerialized.java
...main/java/com/ceb/gjjs/mda/config/MyDateDeSerialized.java
+5
-1
No files found.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/config/MyDateDeSerialized.java
View file @
a9ca9687
...
...
@@ -31,12 +31,16 @@ public class MyDateDeSerialized extends JsonDeserializer {
}
declaredField
.
setAccessible
(
true
);
if
(
StringUtil
.
isNotEmpty
(
source
))
{
Pattern
patternAnnotation
=
declaredField
.
getAnnotation
(
Pattern
.
class
);
String
format
=
declaredField
.
getAnnotation
(
JsonFormat
.
class
).
pattern
();
if
(
format
.
length
()
!=
source
.
length
())
{
ValidatorUtil
.
CHECK_ERR_MSG
.
set
(
patternAnnotation
==
null
?
"时间格式不正确"
:
patternAnnotation
.
message
());
return
null
;
}
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
format
);
try
{
date
=
simpleDateFormat
.
parse
(
source
);
}
catch
(
ParseException
e
)
{
Pattern
patternAnnotation
=
declaredField
.
getAnnotation
(
Pattern
.
class
);
ValidatorUtil
.
CHECK_ERR_MSG
.
set
(
patternAnnotation
==
null
?
"时间格式不正确"
:
patternAnnotation
.
message
());
return
null
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment