diff --git a/cwms-data-api/src/test/java/cwms/cda/helpers/DateUtilsTest.java b/cwms-data-api/src/test/java/cwms/cda/helpers/DateUtilsTest.java index 667d32776..01fbb5188 100644 --- a/cwms-data-api/src/test/java/cwms/cda/helpers/DateUtilsTest.java +++ b/cwms-data-api/src/test/java/cwms/cda/helpers/DateUtilsTest.java @@ -2,8 +2,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import cwms.cda.api.Controllers; import cwms.cda.data.dto.TimeSeries; import java.time.DateTimeException; import java.time.Instant; @@ -122,4 +124,23 @@ void test_PT_doesnt_care_about_zone(){ assertEquals(ptZdt.toInstant(), ptChZdt.toInstant(), "PT-24H should be the same in any zone"); } + @Test + void test_controllers_example_date(){ + ZonedDateTime zdt = DateUtils.parseUserDate(Controllers.EXAMPLE_DATE, "UTC"); + assertNotNull(zdt); + Instant expected = ZonedDateTime.of(2021,6,10,13,0,0,0, + ZoneId.of("PST8PDT")).toInstant(); + assertEquals(expected, zdt.toInstant()); + } + + @Test + void test_DateTimeFormatter_iso_zoned_example(){ + String isoExample = "2011-12-03T10:15:30+01:00[Europe/Paris]"; // Example from java.time.format.DateTimeFormatter javadoc. + ZonedDateTime zdt = DateUtils.parseUserDate(isoExample, "UTC"); + assertNotNull(zdt); + Instant expected = ZonedDateTime.of(2011,12,3,10,15,30,0, + ZoneId.of("Europe/Paris")).toInstant(); + assertEquals(expected, zdt.toInstant()); + } + }