Fix timezone issue in DateTimeFormatterFactory
The DateTimeFormatterFactory introduced in SPR-7121 supports a timeZone property; however, this property is currently not properly supported. This commit addresses this issue by ensuring that the timeZone properly is honored. Issue: SPR-9953
This commit is contained in:
@@ -33,6 +33,7 @@ import org.springframework.util.StringUtils;
|
||||
* or {@link #setStyle(String) style} (considered in that order).
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
* @see #getDateTimeFormatter()
|
||||
* @see #getDateTimeFormatter(DateTimeFormatter)
|
||||
* @since 3.2
|
||||
@@ -100,7 +101,7 @@ public class DateTimeFormatterFactory implements FactoryBean<DateTimeFormatter>
|
||||
public DateTimeFormatter getDateTimeFormatter(DateTimeFormatter fallbackFormatter) {
|
||||
DateTimeFormatter dateTimeFormatter = createDateTimeFormatter();
|
||||
if(dateTimeFormatter != null && this.timeZone != null) {
|
||||
dateTimeFormatter.withZone(DateTimeZone.forTimeZone(this.timeZone));
|
||||
dateTimeFormatter = dateTimeFormatter.withZone(DateTimeZone.forTimeZone(this.timeZone));
|
||||
}
|
||||
return (dateTimeFormatter != null ? dateTimeFormatter : fallbackFormatter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user