Commit 17dc54c4 authored by R.W.Majeed's avatar R.W.Majeed
Browse files

test added for formats with optional parts

parent 6b8c1201
...@@ -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
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment