2020import java .time .Instant ;
2121import java .time .format .DateTimeFormatter ;
2222import java .time .temporal .ChronoUnit ;
23+ import java .util .Locale ;
2324import java .util .Random ;
2425import java .util .stream .Stream ;
2526
@@ -50,44 +51,39 @@ class InstantFormatterTests {
5051
5152 private final InstantFormatter instantFormatter = new InstantFormatter ();
5253
54+
5355 @ ParameterizedTest
5456 @ ArgumentsSource (ISOSerializedInstantProvider .class )
5557 void should_parse_an_ISO_formatted_string_representation_of_an_Instant (String input ) throws ParseException {
5658 Instant expected = DateTimeFormatter .ISO_INSTANT .parse (input , Instant ::from );
57-
58- Instant actual = instantFormatter .parse (input , null );
59-
59+ Instant actual = instantFormatter .parse (input , Locale .US );
6060 assertThat (actual ).isEqualTo (expected );
6161 }
6262
6363 @ ParameterizedTest
6464 @ ArgumentsSource (RFC1123SerializedInstantProvider .class )
6565 void should_parse_an_RFC1123_formatted_string_representation_of_an_Instant (String input ) throws ParseException {
6666 Instant expected = DateTimeFormatter .RFC_1123_DATE_TIME .parse (input , Instant ::from );
67-
68- Instant actual = instantFormatter .parse (input , null );
69-
67+ Instant actual = instantFormatter .parse (input , Locale .US );
7068 assertThat (actual ).isEqualTo (expected );
7169 }
7270
7371 @ ParameterizedTest
7472 @ ArgumentsSource (RandomInstantProvider .class )
7573 void should_serialize_an_Instant_using_ISO_format_and_ignoring_Locale (Instant input ) {
7674 String expected = DateTimeFormatter .ISO_INSTANT .format (input );
77-
78- String actual = instantFormatter .print (input , null );
79-
75+ String actual = instantFormatter .print (input , Locale .US );
8076 assertThat (actual ).isEqualTo (expected );
8177 }
8278
8379 @ ParameterizedTest
8480 @ ArgumentsSource (RandomEpochMillisProvider .class )
8581 void should_parse_into_an_Instant_from_epoch_milli (Instant input ) throws ParseException {
86- Instant actual = instantFormatter .parse (Long .toString (input .toEpochMilli ()), null );
87-
82+ Instant actual = instantFormatter .parse (Long .toString (input .toEpochMilli ()), Locale .US );
8883 assertThat (actual ).isEqualTo (input );
8984 }
9085
86+
9187 private static class RandomInstantProvider implements ArgumentsProvider {
9288
9389 private static final long DATA_SET_SIZE = 10 ;
@@ -109,6 +105,7 @@ Stream<Instant> randomInstantStream(Instant min, Instant max) {
109105 }
110106 }
111107
108+
112109 private static class ISOSerializedInstantProvider extends RandomInstantProvider {
113110
114111 @ Override
@@ -117,6 +114,7 @@ Stream<?> provideArguments() {
117114 }
118115 }
119116
117+
120118 private static class RFC1123SerializedInstantProvider extends RandomInstantProvider {
121119
122120 // RFC-1123 supports only 4-digit years
@@ -130,6 +128,8 @@ Stream<?> provideArguments() {
130128 .map (DateTimeFormatter .RFC_1123_DATE_TIME .withZone (systemDefault ())::format );
131129 }
132130 }
131+
132+
133133 private static final class RandomEpochMillisProvider implements ArgumentsProvider {
134134
135135 private static final long DATA_SET_SIZE = 10 ;
0 commit comments