diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml
index dad3956b82c..a36da64db7c 100755
--- a/spring-boot-autoconfigure/pom.xml
+++ b/spring-boot-autoconfigure/pom.xml
@@ -505,6 +505,11 @@
thymeleaf-extras-conditionalcomments
true
+
+ org.thymeleaf.extras
+ thymeleaf-extras-java8time
+ true
+
org.thymeleaf.extras
thymeleaf-extras-springsecurity4
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
index 247eecc7708..3369fd063c6 100644
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
@@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.thymeleaf.dialect.IDialect;
import org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect;
+import org.thymeleaf.extras.java8time.dialect.Java8TimeDialect;
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.spring4.resourceresolver.SpringResourceResourceResolver;
@@ -40,6 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnJava;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
@@ -61,6 +63,7 @@ import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
* @author Andy Wilkinson
* @author Stephane Nicoll
* @author Brian Clozel
+ * @author Eddú Meléndez
*/
@Configuration
@EnableConfigurationProperties(ThymeleafProperties.class)
@@ -190,6 +193,19 @@ public class ThymeleafAutoConfiguration {
}
+ @Configuration
+ @ConditionalOnJava(ConditionalOnJava.JavaVersion.EIGHT)
+ @ConditionalOnClass({ Java8TimeDialect.class })
+ protected static class ThymeleafJava8TimeDialect {
+
+ @Bean
+ @ConditionalOnMissingBean
+ public Java8TimeDialect java8TimeDialect() {
+ return new Java8TimeDialect();
+ }
+
+ }
+
@Configuration
@ConditionalOnClass({ Servlet.class })
@ConditionalOnWebApplication
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
index 8585fef2270..16546d6524b 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
@@ -54,6 +54,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Dave Syer
* @author Stephane Nicoll
+ * @author Eddú Meléndez
*/
public class ThymeleafAutoConfigurationTests {
@@ -172,6 +173,17 @@ public class ThymeleafAutoConfigurationTests {
assertEquals("", result);
}
+ @Test
+ public void useJava8TimeDialect() throws Exception {
+ this.context.register(ThymeleafAutoConfiguration.class,
+ PropertyPlaceholderAutoConfiguration.class);
+ this.context.refresh();
+ TemplateEngine engine = this.context.getBean(TemplateEngine.class);
+ Context attrs = new Context(Locale.UK);
+ String result = engine.process("java8time-dialect", attrs);
+ assertEquals("2015-11-24", result);
+ }
+
@Test
public void renderTemplate() throws Exception {
this.context.register(ThymeleafAutoConfiguration.class,
diff --git a/spring-boot-autoconfigure/src/test/resources/templates/java8time-dialect.html b/spring-boot-autoconfigure/src/test/resources/templates/java8time-dialect.html
new file mode 100644
index 00000000000..3bba41f49b9
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/resources/templates/java8time-dialect.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml
index 0e26ef6f4c8..aa1128eb1da 100644
--- a/spring-boot-dependencies/pom.xml
+++ b/spring-boot-dependencies/pom.xml
@@ -153,6 +153,7 @@
2.1.1.RELEASE
1.3.1
1.3
+ 2.1.0.RELEASE
8.0.30
1.3.14.Final
1.7
@@ -1963,6 +1964,11 @@
thymeleaf-extras-conditionalcomments
${thymeleaf-extras-conditionalcomments.version}
+
+ org.thymeleaf.extras
+ thymeleaf-extras-java8time
+ ${thymeleaf-extras-java8time.version}
+
org.thymeleaf.extras
thymeleaf-extras-springsecurity4