From e1cfc8212e31d7549ebe91b6a360d57a1a96588d Mon Sep 17 00:00:00 2001 From: James Agnew Date: Fri, 9 Jun 2017 15:36:19 -0400 Subject: [PATCH] Merge in patch from #655 --- .../primitive/BaseDateTimeDtDstu2Test.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java index 7d5ce8aef60..60499d74fc6 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java @@ -43,13 +43,13 @@ public class BaseDateTimeDtDstu2Test { Date from = Date.from(ldt.toInstant(ZoneOffset.UTC)); InstantDt type = (InstantDt) new InstantDt(from).setTimeZoneZulu(true); String encoded = type.getValueAsString(); - - ourLog.info("LDT: "+ ldt.toString()); - ourLog.info("Expected: "+"1960-09-07T00:44:25.012"); - ourLog.info("Actual: "+encoded); - + + ourLog.info("LDT: " + ldt.toString()); + ourLog.info("Expected: " + "1960-09-07T00:44:25.012"); + ourLog.info("Actual: " + encoded); + assertEquals("1960-09-07T00:44:25.012Z", encoded); - + type = new InstantDt(encoded); assertEquals(1960, type.getYear().intValue()); assertEquals(8, type.getMonth().intValue()); // 0-indexed unlike LocalDateTime.of @@ -65,11 +65,11 @@ public class BaseDateTimeDtDstu2Test { public void testFromTime() { long millis; InstantDt dt; - + millis = 1466022208001L; String expected = "2016-06-15T20:23:28.001Z"; validate(millis, expected); - + millis = 1466022208123L; expected = "2016-06-15T20:23:28.123Z"; validate(millis, expected); @@ -77,13 +77,12 @@ public class BaseDateTimeDtDstu2Test { millis = 1466022208100L; expected = "2016-06-15T20:23:28.100Z"; validate(millis, expected); - + millis = 1466022208000L; expected = "2016-06-15T20:23:28.000Z"; validate(millis, expected); - - } + } private void validate(long millis, String expected) { InstantDt dt; @@ -93,13 +92,12 @@ public class BaseDateTimeDtDstu2Test { assertEquals(millis % 1000, dt.getMillis().longValue()); assertEquals((millis % 1000) * BaseDateTimeDt.NANOS_PER_MILLIS, dt.getNanos().longValue()); - + dt = new InstantDt(); dt.setTimeZone(TimeZone.getTimeZone("GMT+0:00")); dt.setValue(new Date(millis)); assertEquals(expected.replace("Z", "+00:00"), dt.getValueAsString()); } - @Test public void testSetPartialsYearFromExisting() { @@ -262,7 +260,6 @@ public class BaseDateTimeDtDstu2Test { verifyFails("1974-A2-25"); verifyFails("1974-12-A5"); - // Date shouldn't have a time zone verifyFails("1974-12-25Z"); verifyFails("1974-12-25+10:00");