3737import org .apache .logging .log4j .core .util .internal .instant .InstantPatternDynamicFormatter .DynamicPatternSequence ;
3838import org .apache .logging .log4j .core .util .internal .instant .InstantPatternDynamicFormatter .PatternSequence ;
3939import org .apache .logging .log4j .core .util .internal .instant .InstantPatternDynamicFormatter .StaticPatternSequence ;
40+ import org .apache .logging .log4j .util .Constants ;
4041import org .junit .jupiter .api .Test ;
4142import org .junit .jupiter .params .ParameterizedTest ;
4243import org .junit .jupiter .params .provider .Arguments ;
@@ -253,13 +254,17 @@ void should_recognize_patterns_of_minute_precision(final String pattern) {
253254 }
254255
255256 @ ParameterizedTest
256- @ ValueSource (
257- strings = {
257+ @ MethodSource ("hourPrecisionPatterns" )
258+ void should_recognize_patterns_of_hour_precision (final String pattern ) {
259+ assertPatternPrecision (pattern , ChronoUnit .HOURS );
260+ }
261+
262+ static List <String > hourPrecisionPatterns () {
263+ final List <String > java8Patterns = new ArrayList <>(asList (
258264 // Basics
259265 "H" ,
260266 "HH" ,
261267 "a" ,
262- "B" ,
263268 "h" ,
264269 "K" ,
265270 "k" ,
@@ -269,7 +274,6 @@ void should_recognize_patterns_of_minute_precision(final String pattern) {
269274 "X" ,
270275 "O" ,
271276 "z" ,
272- "v" ,
273277 "VV" ,
274278 // Mixed with other stuff
275279 "yyyy-MM-dd HH" ,
@@ -279,10 +283,12 @@ void should_recognize_patterns_of_minute_precision(final String pattern) {
279283 "ddHH" ,
280284 // Single-quoted text containing nanosecond and millisecond directives
281285 "yyyy-MM-dd'S'HH" ,
282- "yyyy-MM-dd'n'HH"
283- })
284- void should_recognize_patterns_of_hour_precision (final String pattern ) {
285- assertPatternPrecision (pattern , ChronoUnit .HOURS );
286+ "yyyy-MM-dd'n'HH" ));
287+ if (Constants .JAVA_MAJOR_VERSION > 8 ) {
288+ java8Patterns .add ("B" );
289+ java8Patterns .add ("v" );
290+ }
291+ return java8Patterns ;
286292 }
287293
288294 private static void assertPatternPrecision (final String pattern , final ChronoUnit expectedPrecision ) {
0 commit comments