Skip to content

Commit 8e25e32

Browse files
committed
Polishing
1 parent 4b0bf16 commit 8e25e32

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

spring-context/src/main/java/org/springframework/format/datetime/standard/Jsr310DateTimeFormatAnnotationFormatterFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -96,6 +96,8 @@ else if (formatter == DateTimeFormatter.ISO_DATE_TIME) {
9696
@Override
9797
@SuppressWarnings("unchecked")
9898
public Parser<?> getParser(DateTimeFormat annotation, Class<?> fieldType) {
99+
DateTimeFormatter formatter = getFormatter(annotation, fieldType);
100+
99101
List<String> resolvedFallbackPatterns = new ArrayList<>();
100102
for (String fallbackPattern : annotation.fallbackPatterns()) {
101103
String resolvedFallbackPattern = resolveEmbeddedValue(fallbackPattern);
@@ -104,7 +106,6 @@ public Parser<?> getParser(DateTimeFormat annotation, Class<?> fieldType) {
104106
}
105107
}
106108

107-
DateTimeFormatter formatter = getFormatter(annotation, fieldType);
108109
return new TemporalAccessorParser((Class<? extends TemporalAccessor>) fieldType,
109110
formatter, resolvedFallbackPatterns.toArray(new String[0]), annotation);
110111
}

spring-context/src/main/java/org/springframework/format/datetime/standard/TemporalAccessorParser.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -71,7 +71,8 @@ public TemporalAccessorParser(Class<? extends TemporalAccessor> temporalAccessor
7171
}
7272

7373
TemporalAccessorParser(Class<? extends TemporalAccessor> temporalAccessorType, DateTimeFormatter formatter,
74-
@Nullable String[] fallbackPatterns, @Nullable Object source) {
74+
@Nullable String[] fallbackPatterns, @Nullable Object source) {
75+
7576
this.temporalAccessorType = temporalAccessorType;
7677
this.formatter = formatter;
7778
this.fallbackPatterns = fallbackPatterns;
@@ -100,8 +101,8 @@ public TemporalAccessor parse(String text, Locale locale) throws ParseException
100101
}
101102
if (this.source != null) {
102103
throw new DateTimeParseException(
103-
String.format("Unable to parse date time value \"%s\" using configuration from %s", text, this.source),
104-
text, ex.getErrorIndex(), ex);
104+
String.format("Unable to parse date time value \"%s\" using configuration from %s", text, this.source),
105+
text, ex.getErrorIndex(), ex);
105106
}
106107
// else rethrow original exception
107108
throw ex;

0 commit comments

Comments
 (0)