Back-End/Spring

thymeleaf 사용 시 날짜포맷팅

어렵다어려웡 2021. 3. 1. 20:10

1. build.gradle

 

dependencies {
	compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-java8time'
}

 

2. html 에서 테스트 진행

<html lang="en" xmlns:th="http://www.thymeleaf.org">

 <!-- 나머지 태그 생략 --> 
 	
    <th:block th:each="dto : ${result}">
		<div>
        	[[ ${#temporals.format(dto.regDate, "yyyy-MM-dd" }  ]] 
        </div>
    </th:block>