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
a50ec980
Commit
a50ec980
authored
5 years ago
by
Jonas Blatt
Browse files
Options
Downloads
Patches
Plain Diff
Add date formatted text
parent
9317065b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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/base/utils/boundary/impl/DateBoundary.java
+49
-2
49 additions, 2 deletions
...ikoblenz/fgbks/base/utils/boundary/impl/DateBoundary.java
with
49 additions
and
2 deletions
dmnverifierapi/src/main/java/de/unikoblenz/fgbks/base/utils/boundary/impl/DateBoundary.java
+
49
−
2
View file @
a50ec980
...
...
@@ -2,11 +2,17 @@ package de.unikoblenz.fgbks.base.utils.boundary.impl;
import
static
de
.
unikoblenz
.
fgbks
.
base
.
utils
.
boundary
.
BoundType
.
EXCLUSIVE
;
import
static
de
.
unikoblenz
.
fgbks
.
base
.
utils
.
boundary
.
BoundType
.
INCLUSIVE
;
import
static
java
.
time
.
format
.
DateTimeFormatter
.
ISO_LOCAL_DATE
;
import
static
java
.
time
.
temporal
.
ChronoField
.
HOUR_OF_DAY
;
import
static
java
.
time
.
temporal
.
ChronoField
.
MINUTE_OF_HOUR
;
import
static
java
.
time
.
temporal
.
ChronoField
.
SECOND_OF_MINUTE
;
import
de.unikoblenz.fgbks.base.utils.boundary.AbstractGrowingBoundary
;
import
de.unikoblenz.fgbks.base.utils.boundary.BoundType
;
import
de.unikoblenz.fgbks.base.utils.boundary.BoundaryParseException
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatterBuilder
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.apache.commons.lang3.Validate
;
...
...
@@ -19,9 +25,28 @@ public class DateBoundary extends AbstractGrowingBoundary<LocalDateTime> {
+
dateGroupName
+
">(?:19|20)\\d{2}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d)\"\\)$"
;
public
static
final
Pattern
datePattern
=
Pattern
.
compile
(
datePatternString
);
public
static
final
DateTimeFormatter
CAMUNDA_DATE_TIME_FORMAT
;
static
{
CAMUNDA_DATE_TIME_FORMAT
=
new
DateTimeFormatterBuilder
()
.
appendLiteral
(
"date and time(\""
)
.
parseCaseInsensitive
()
.
append
(
ISO_LOCAL_DATE
)
.
appendLiteral
(
'T'
)
.
appendValue
(
HOUR_OF_DAY
,
2
)
.
appendLiteral
(
':'
)
.
appendValue
(
MINUTE_OF_HOUR
,
2
)
.
optionalStart
()
.
appendLiteral
(
':'
)
.
appendValue
(
SECOND_OF_MINUTE
,
2
)
.
appendLiteral
(
"\")"
)
.
toFormatter
();
}
public
DateBoundary
(
String
text
)
{
super
(
text
,
LocalDateTime
.
class
);
System
.
out
.
println
(
"---> "
+
getParsedText
());
}
private
DateBoundary
()
{
...
...
@@ -45,12 +70,12 @@ public class DateBoundary extends AbstractGrowingBoundary<LocalDateTime> {
@Override
public
LocalDateTime
getMinValue
()
{
return
LocalDateTime
.
M
AX
;
return
LocalDateTime
.
M
IN
;
}
@Override
public
LocalDateTime
getMaxValue
()
{
return
LocalDateTime
.
M
IN
;
return
LocalDateTime
.
M
AX
;
}
@Override
...
...
@@ -119,4 +144,26 @@ public class DateBoundary extends AbstractGrowingBoundary<LocalDateTime> {
throw
new
BoundaryParseException
(
"Date value "
+
this
.
getText
()
+
" couldn't be parsed."
);
}
}
@Override
public
String
getParsedText
()
{
if
(
lowerBound
.
equals
(
getMinValue
())
&&
upperBound
.
equals
(
getMaxValue
()))
{
return
""
;
}
StringBuilder
sb
=
new
StringBuilder
();
if
(
lowerBound
.
equals
(
getMinValue
()))
{
sb
.
append
(
"< "
);
sb
.
append
(
CAMUNDA_DATE_TIME_FORMAT
.
format
(
upperBound
));
}
else
if
(
upperBound
.
equals
(
getMaxValue
()))
{
sb
.
append
(
"> "
);
sb
.
append
(
CAMUNDA_DATE_TIME_FORMAT
.
format
(
lowerBound
));
}
else
{
sb
.
append
(
"["
);
sb
.
append
(
CAMUNDA_DATE_TIME_FORMAT
.
format
(
lowerBound
));
sb
.
append
(
".."
);
sb
.
append
(
CAMUNDA_DATE_TIME_FORMAT
.
format
(
upperBound
));
sb
.
append
(
"]"
);
}
return
sb
.
toString
();
}
}
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