Fix locale for DateTimeUtilTests

This commit is contained in:
dotasek 2022-03-15 13:52:51 -04:00
parent 02968b9b7a
commit ce796e81bc
1 changed files with 37 additions and 22 deletions

View File

@ -1,11 +1,14 @@
package org.hl7.fhir.utilities;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.stream.Stream;
@ -44,13 +47,25 @@ public class DateTimeUtilTests {
Arguments.of(TemporalPrecisionEnum.YEAR, new Date("2002/02/04"), "dummyValueAsString"),
Arguments.of(TemporalPrecisionEnum.MONTH, new Date("2002/02/04"), "dummyValueAsString"),
Arguments.of(TemporalPrecisionEnum.DAY, new Date("2002/02/04"), "dummyValueAsString"),
Arguments.of(TemporalPrecisionEnum.MILLI, new Date("2002/02/04"), "4-Feb-2002 12:00:00 AM"),
Arguments.of(TemporalPrecisionEnum.SECOND, new Date("2002/02/04"), "4-Feb-2002 12:00:00 AM"),
Arguments.of(TemporalPrecisionEnum.MINUTE, new Date("2002/02/04"), "4-Feb-2002 12:00:00 AM")
Arguments.of(TemporalPrecisionEnum.MILLI, new Date("2002/02/04"), "04-Feb-2002 00:00:00"),
Arguments.of(TemporalPrecisionEnum.SECOND, new Date("2002/02/04"), "04-Feb-2002 00:00:00"),
Arguments.of(TemporalPrecisionEnum.MINUTE, new Date("2002/02/04"), "04-Feb-2002 00:00:00")
);
}
private static final Locale defaultLocale = Locale.getDefault();;
@BeforeAll
public static void beforeAll() {
Locale.setDefault(Locale.UK);
}
@AfterAll
public static void afterAll() {
Locale.setDefault(defaultLocale);
}
@ParameterizedTest
@MethodSource("getToHumanDisplayLocalTimezoneParams")
public void testToHumanDisplayLocalTimezone(TemporalPrecisionEnum thePrecision, Date theValue, String expected){