Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Verification for Decision Model and Notation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Blatt
Verification for Decision Model and Notation
Commits
157acdb9
Commit
157acdb9
authored
5 years ago
by
Jonas Blatt
Browse files
Options
Downloads
Patches
Plain Diff
Check Date format
parent
68199a13
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dmnverifierapi/src/main/java/de/unikoblenz/fgbks/core/dmn/verification/verifier/impl/DateVerifier.java
+27
-16
27 additions, 16 deletions
...bks/core/dmn/verification/verifier/impl/DateVerifier.java
with
27 additions
and
16 deletions
dmnverifierapi/src/main/java/de/unikoblenz/fgbks/core/dmn/verification/verifier/impl/DateVerifier.java
+
27
−
16
View file @
157acdb9
...
...
@@ -40,24 +40,35 @@ public class DateVerifier extends AbstractVerifier {
private
void
checkDateValue
(
VDmnValue
dateValue
)
{
if
(!
dateValue
.
getText
().
isEmpty
())
{
// 1. check pattern
Matcher
matcher
=
datePattern
.
matcher
(
dateValue
.
getText
());
if
(!
matcher
.
find
())
{
for
(
String
dateStringValue
:
dateValue
.
getText
()
.
replace
(
"<"
,
""
)
.
replace
(
">"
,
""
)
.
replace
(
"["
,
""
)
.
replace
(
"]"
,
""
)
.
split
(
".."
))
{
checkCorrectDate
(
dateValue
,
dateStringValue
);
}
}
}
private
void
checkCorrectDate
(
VDmnValue
dateValue
,
String
dateStringValue
)
{
// 1. check pattern
Matcher
matcher
=
datePattern
.
matcher
(
dateStringValue
);
if
(!
matcher
.
find
())
{
vref
.
addElement
(
VerificationResultEntryElement
.
create
(
dateValue
));
vref
.
addToEntry
(
VerificationClassification
.
ERROR
,
"Date value '%s' does not match 'date and time(\"yyyy-mm-ddTHH:MM:SS\").'"
,
dateStringValue
);
}
else
{
// 2. check correct date
String
dateTime
=
matcher
.
group
(
"datetime"
);
try
{
LocalDateTime
.
parse
(
dateTime
);
}
catch
(
DateTimeParseException
e
)
{
vref
.
addElement
(
VerificationResultEntryElement
.
create
(
dateValue
));
vref
.
addToEntry
(
VerificationClassification
.
ERROR
,
"Date value '%s' does not match 'date and time(\"yyyy-mm-ddTHH:MM:SS\").'"
,
dateValue
.
getText
());
}
else
{
// 2. check correct date
String
dateTime
=
matcher
.
group
(
"datetime"
);
try
{
LocalDateTime
.
parse
(
dateTime
);
}
catch
(
DateTimeParseException
e
)
{
vref
.
addElement
(
VerificationResultEntryElement
.
create
(
dateValue
));
vref
.
addToEntry
(
VerificationClassification
.
ERROR
,
"Date value '%s' is no valid date."
,
dateTime
);
}
VerificationClassification
.
ERROR
,
"Date value '%s' is no valid date."
,
dateTime
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment