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
2f38d516
Commit
2f38d516
authored
Jan 02, 2024
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
5015430e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
MyDateDeSerialized.java
...main/java/com/ceb/gjjs/mda/config/MyDateDeSerialized.java
+13
-7
No files found.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/config/MyDateDeSerialized.java
View file @
2f38d516
package
com
.
ceb
.
gjjs
.
mda
.
config
;
package
com
.
ceb
.
gjjs
.
mda
.
config
;
import
com.brilliance.eibs.util.StringUtil
;
import
com.brilliance.eibs.util.StringUtil
;
import
com.brilliance.mda.runtime.annotation.RelPath
;
import
com.ceb.gjjs.mda.util.ValidatorUtil
;
import
com.ceb.gjjs.mda.util.ValidatorUtil
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.core.JsonParser
;
import
com.fasterxml.jackson.core.JsonParser
;
import
com.fasterxml.jackson.databind.DeserializationContext
;
import
com.fasterxml.jackson.databind.DeserializationContext
;
import
com.fasterxml.jackson.databind.JsonDeserializer
;
import
com.fasterxml.jackson.databind.JsonDeserializer
;
import
javax.validation.constraints.Pattern
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.text.ParseException
;
import
java.text.ParseException
;
...
@@ -31,17 +31,23 @@ public class MyDateDeSerialized extends JsonDeserializer {
...
@@ -31,17 +31,23 @@ public class MyDateDeSerialized extends JsonDeserializer {
}
}
declaredField
.
setAccessible
(
true
);
declaredField
.
setAccessible
(
true
);
if
(
StringUtil
.
isNotEmpty
(
source
))
{
if
(
StringUtil
.
isNotEmpty
(
source
))
{
String
msg
=
declaredField
.
getAnnotation
(
RelPath
.
class
).
message
(
);
Pattern
annotation
=
declaredField
.
getAnnotation
(
Pattern
.
class
);
String
format
=
declaredField
.
getAnnotation
(
JsonFormat
.
class
).
pattern
();
String
format
=
declaredField
.
getAnnotation
(
JsonFormat
.
class
).
pattern
();
if
(
format
.
length
()
!=
source
.
length
())
{
//
if (format.length() != source.length()) {
ValidatorUtil
.
CHECK_ERR_MSG
.
set
(
StringUtil
.
isEmpty
(
msg
)
?
"时间格式不正确"
:
msg
);
// ValidatorUtil.CHECK_ERR_MSG.set(annotation.message()
);
return
null
;
//
return null;
}
//
}
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
format
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
format
);
try
{
try
{
date
=
simpleDateFormat
.
parse
(
source
);
date
=
simpleDateFormat
.
parse
(
source
);
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
ValidatorUtil
.
CHECK_ERR_MSG
.
set
(
StringUtil
.
isEmpty
(
msg
)
?
"时间格式不正确"
:
msg
);
ValidatorUtil
.
CHECK_ERR_MSG
.
set
(
annotation
.
message
());
return
null
;
}
String
regexp
=
annotation
.
regexp
();
boolean
match
=
source
.
matches
(
regexp
);
if
(!
match
)
{
ValidatorUtil
.
CHECK_ERR_MSG
.
set
(
annotation
.
message
());
return
null
;
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