Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Raphael
histream
Commits
17dc54c4
Commit
17dc54c4
authored
Aug 04, 2015
by
R.W.Majeed
Browse files
test added for formats with optional parts
parent
6b8c1201
Changes
1
Hide whitespace changes
Inline
Side-by-side
histream-core/src/test/java/de/sekmi/histream/TestDateTimeAccuracy.java
View file @
17dc54c4
...
@@ -2,9 +2,12 @@ package de.sekmi.histream;
...
@@ -2,9 +2,12 @@ package de.sekmi.histream;
import
java.text.ParsePosition
;
import
java.text.ParsePosition
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatterBuilder
;
import
java.time.format.ResolverStyle
;
import
java.time.temporal.ChronoField
;
import
java.time.temporal.ChronoField
;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.TemporalAccessor
;
import
java.time.temporal.TemporalAccessor
;
import
java.time.temporal.TemporalField
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -13,7 +16,6 @@ public class TestDateTimeAccuracy {
...
@@ -13,7 +16,6 @@ public class TestDateTimeAccuracy {
@Test
@Test
public
void
testParseYYYYDD
(){
public
void
testParseYYYYDD
(){
//DateTimeAccuracy a = DateTimeAccuracy.parse(formatter, text)
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"M.u"
);
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"M.u"
);
String
text
=
"02.2003"
;
String
text
=
"02.2003"
;
DateTimeAccuracy
a
=
DateTimeAccuracy
.
parse
(
formatter
,
text
);
DateTimeAccuracy
a
=
DateTimeAccuracy
.
parse
(
formatter
,
text
);
...
@@ -21,5 +23,21 @@ public class TestDateTimeAccuracy {
...
@@ -21,5 +23,21 @@ public class TestDateTimeAccuracy {
Assert
.
assertEquals
(
2
,
a
.
get
(
ChronoField
.
MONTH_OF_YEAR
));
Assert
.
assertEquals
(
2
,
a
.
get
(
ChronoField
.
MONTH_OF_YEAR
));
Assert
.
assertEquals
(
2003
,
a
.
get
(
ChronoField
.
YEAR
));
Assert
.
assertEquals
(
2003
,
a
.
get
(
ChronoField
.
YEAR
));
}
}
@Test
public
void
testFormatExceedsText
(){
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"d.M.u[ H[:m[:s]]]"
);
formatter
.
withResolverStyle
(
ResolverStyle
.
STRICT
);
DateTimeFormatterBuilder
b
=
new
DateTimeFormatterBuilder
();
DateTimeAccuracy
a
;
a
=
DateTimeAccuracy
.
parse
(
formatter
,
"01.02.2003"
);
Assert
.
assertEquals
(
ChronoUnit
.
DAYS
,
a
.
getAccuracy
());
a
=
DateTimeAccuracy
.
parse
(
formatter
,
"01.02.2003 13"
);
//Assert.assertEquals(ChronoUnit.HOURS,a.getAccuracy());
//will have second resolution (implicit)
// TODO correct accuracy
}
// TODO: further tests
// TODO: further tests
}
}
Write
Preview
Supports
Markdown
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