String형식을 Date형식으로 변환하는 경우
<div th:text="${#temporals.format(item.regDt, 'yyyy.MM.dd HH:mm:ss')}"></div>
Date형식을 Date형식으로 변환하는 경우
<div th:text="${#dates.format(item.regDt, 'yyyy.MM.dd HH:mm:ss')}"></div>
그외 포맷형식과 날짜 관련 메소드
thymeleaf 공식문서를 통하여 확인이 가능합니다.
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#dates
/*
* ======================================================================
* See javadoc API for class org.thymeleaf.expression.Dates
* ======================================================================
*/
// 값을 standard 포맷에 맞게 변환
${#dates.format(date)}
${#dates.arrayFormat(datesArray)}
${#dates.listFormat(datesList)}
${#dates.setFormat(datesSet)}
// 값을 ISO8601 포맷에 맞게 변환
${#dates.formatISO(date)}
${#dates.arrayFormatISO(datesArray)}
${#dates.listFormatISO(datesList)}
${#dates.setFormatISO(datesSet)}
// 값을 지정된 포맷에 맞게 변환
${#dates.format(date, 'dd/MMM/yyyy HH:mm')}
${#dates.arrayFormat(datesArray, 'dd/MMM/yyyy HH:mm')}
${#dates.listFormat(datesList, 'dd/MMM/yyyy HH:mm')}
${#dates.setFormat(datesSet, 'dd/MMM/yyyy HH:mm')}
// dates 객체의 특정 요소값
${#dates.day(date)}
${#dates.month(date)}
${#dates.monthName(date)}
${#dates.monthNameShort(date)}
${#dates.year(date)}
${#dates.dayOfWeek(date)}
${#dates.dayOfWeekName(date)}
${#dates.dayOfWeekNameShort(date)}
${#dates.hour(date)}
${#dates.minute(date)}
${#dates.second(date)}
${#dates.millisecond(date)}
// dates 객체 생성
${#dates.create(year,month,day)}
${#dates.create(year,month,day,hour,minute)}
${#dates.create(year,month,day,hour,minute,second)}
${#dates.create(year,month,day,hour,minute,second,millisecond)}
${#dates.createNow()}
${#dates.createNowForTimeZone()}
${#dates.createToday()}
${#dates.createTodayForTimeZone()}
반응형
댓글